Skip to content
  1. Aug 12, 2021
    • Dongliang Mu's avatar
      spi: meson-spicc: fix memory leak in meson_spicc_remove · 683b47d0
      Dongliang Mu authored
      commit 8311ee21
      
       upstream.
      
      In meson_spicc_probe, the error handling code needs to clean up master
      by calling spi_master_put, but the remove function does not have this
      function call. This will lead to memory leak of spicc->master.
      
      Reported-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Fixes: 454fa271
      
      ("spi: Add Meson SPICC driver")
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Link: https://lore.kernel.org/r/20210720100116.1438974-1-mudongliangabcd@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      683b47d0
    • Sean Christopherson's avatar
      KVM: x86/mmu: Fix per-cpu counter corruption on 32-bit builds · 4af3486a
      Sean Christopherson authored
      commit d5aaad6f upstream.
      
      Take a signed 'long' instead of an 'unsigned long' for the number of
      pages to add/subtract to the total number of pages used by the MMU.  This
      fixes a zero-extension bug on 32-bit kernels that effectively corrupts
      the per-cpu counter used by the shrinker.
      
      Per-cpu counters take a signed 64-bit value on both 32-bit and 64-bit
      kernels, whereas kvm_mod_used_mmu_pages() takes an unsigned long and thus
      an unsigned 32-bit value on 32-bit kernels.  As a result, the value used
      to adjust the per-cpu counter is zero-extended (unsigned -> signed), not
      sign-extended (signed -> signed), and so KVM's intended -1 gets morphed to
      4294967295 and effectively corrupts the counter.
      
      This was found by a staggering amount of sheer dumb luck when running
      kvm-unit-tests on a 32-bit KVM build.  The shrinker just happened to kick
      in while running tests and do_shrink_slab() logged an error about trying
      to free a negative number of objects.  The truly lucky part is that the
      kernel just happened to be a slightly stale build, as the shrinker no
      longer yells about negative objects as of commit 18bb473e ("mm:
      vmscan: shrink deferred objects proportional to priority").
      
       vmscan: shrink_slab: mmu_shrink_scan+0x0/0x210 [kvm] negative objects to delete nr=-858993460
      
      Fixes: bc8a3d89
      
       ("kvm: mmu: Fix overflow on kvm mmu page limit calculation")
      Cc: stable@vger.kernel.org
      Cc: Ben Gardon <bgardon@google.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20210804214609.1096003-1-seanjc@google.com>
      Reviewed-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4af3486a
    • Paolo Bonzini's avatar
      KVM: x86: accept userspace interrupt only if no event is injected · 360928c5
      Paolo Bonzini authored
      commit fa7a549d
      
       upstream.
      
      Once an exception has been injected, any side effects related to
      the exception (such as setting CR2 or DR6) have been taked place.
      Therefore, once KVM sets the VM-entry interruption information
      field or the AMD EVENTINJ field, the next VM-entry must deliver that
      exception.
      
      Pending interrupts are processed after injected exceptions, so
      in theory it would not be a problem to use KVM_INTERRUPT when
      an injected exception is present.  However, DOSEMU is using
      run->ready_for_interrupt_injection to detect interrupt windows
      and then using KVM_SET_SREGS/KVM_SET_REGS to inject the
      interrupt manually.  For this to work, the interrupt window
      must be delayed after the completion of the previous event
      injection.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarStas Sergeev <stsp2@yandex.ru>
      Tested-by: default avatarStas Sergeev <stsp2@yandex.ru>
      Fixes: 71cc849b
      
       ("KVM: x86: Fix split-irqchip vs interrupt injection window request")
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      360928c5
    • Zheyu Ma's avatar
      pcmcia: i82092: fix a null pointer dereference bug · 0c83af3b
      Zheyu Ma authored
      commit e39cdacf
      
       upstream.
      
      During the driver loading process, the 'dev' field was not assigned, but
      the 'dev' field was referenced in the subsequent 'i82092aa_set_mem_map'
      function.
      
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      CC: <stable@vger.kernel.org>
      [linux@dominikbrodowski.net: shorten commit message, add Cc to stable]
      Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c83af3b
    • Maciej W. Rozycki's avatar
      MIPS: Malta: Do not byte-swap accesses to the CBUS UART · 0d631eee
      Maciej W. Rozycki authored
      commit 9a936d6c upstream.
      
      Correct big-endian accesses to the CBUS UART, a Malta on-board discrete
      TI16C550C part wired directly to the system controller's device bus, and
      do not use byte swapping with the 32-bit accesses to the device.
      
      The CBUS is used for devices such as the boot flash memory needed early
      on in system bootstrap even before PCI has been initialised.  Therefore
      it uses the system controller's device bus, which follows the endianness
      set with the CPU, which means no byte-swapping is ever required for data
      accesses to CBUS, unlike with PCI.
      
      The CBUS UART uses the UPIO_MEM32 access method, that is the `readl' and
      `writel' MMIO accessors, which on the MIPS platform imply byte-swapping
      with PCI systems.  Consequently the wrong byte lane is accessed with the
      big-endian configuration and the UART is not correctly accessed.
      
      As it happens the UPIO_MEM32BE access method makes use of the `ioread32'
      and `iowrite32' MMIO accessors, which still use `readl' and `writel'
      respectively, however they byte-swap data passed, effectively cancelling
      swapping done with the accessors themselves and making it suitable for
      the CBUS UART.
      
      Make the CBUS UART switch between UPIO_MEM32 and UPIO_MEM32BE then,
      based on the endianness selected.  With this change in place the device
      is correctly recognised with big-endian Malta at boot, along with the
      Super I/O devices behind PCI:
      
      Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled
      printk: console [ttyS0] disabled
      serial8250.0: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
      printk: console [ttyS0] enabled
      printk: bootconsole [uart8250] disabled
      serial8250.0: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
      serial8250.0: ttyS2 at MMIO 0x1f000900 (irq = 20, base_baud = 230400) is a 16550A
      
      Fixes: e7c4782f
      
       ("[MIPS] Put an end to <asm/serial.h>'s long and annyoing existence")
      Cc: stable@vger.kernel.org # v2.6.23+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260524430.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d631eee
    • Maciej W. Rozycki's avatar
      serial: 8250: Mask out floating 16/32-bit bus bits · 2c39c32f
      Maciej W. Rozycki authored
      commit e5227c51 upstream.
      
      Make sure only actual 8 bits of the IIR register are used in determining
      the port type in `autoconfig'.
      
      The `serial_in' port accessor returns the `unsigned int' type, meaning
      that with UPIO_AU, UPIO_MEM16, UPIO_MEM32, and UPIO_MEM32BE access types
      more than 8 bits of data are returned, of which the high order bits will
      often come from bus lines that are left floating in the data phase.  For
      example with the MIPS Malta board's CBUS UART, where the registers are
      aligned on 8-byte boundaries and which uses 32-bit accesses, data as
      follows is returned:
      
      YAMON> dump -32 0xbf000900 0x40
      
      BF000900: 1F000942 1F000942 1F000900 1F000900  ...B...B........
      BF000910: 1F000901 1F000901 1F000900 1F000900  ................
      BF000920: 1F000900 1F000900 1F000960 1F000960  ...........`...`
      BF000930: 1F000900 1F000900 1F0009FF 1F0009FF  ................
      
      YAMON>
      
      Evidently high-order 24 bits return values previously driven in the
      address phase (the 3 highest order address bits used with the command
      above are masked out in the simple virtual address mapping used here and
      come out at zeros on the external bus), a common scenario with bus lines
      left floating, due to bus capacitance.
      
      Consequently when the value of IIR, mapped at 0x1f000910, is retrieved
      in `autoconfig', it comes out at 0x1f0009c1 and when it is right-shifted
      by 6 and then assigned to 8-bit `scratch' variable, the value calculated
      is 0x27, not one of 0, 1, 2, 3 expected in port type determination.
      
      Fix the issue then, by assigning the value returned from `serial_in' to
      `scratch' first, which masks out 24 high-order bits retrieved, and only
      then right-shift the resulting 8-bit data quantity, producing the value
      of 3 in this case, as expected.  Fix the same issue in `serial_dl_read'.
      
      The problem first appeared with Linux 2.6.9-rc3 which predates our repo
      history, but the origin could be identified with the old MIPS/Linux repo
      also at: <git://git.kernel.org/pub/scm/linux/kernel/git/ralf/linux.git>
      as commit e0d2356c0777 ("Merge with Linux 2.6.9-rc3."), where code in
      `serial_in' was updated with this case:
      
      +	case UPIO_MEM32:
      +		return readl(up->port.membase + offset);
      +
      
      which made it produce results outside the unsigned 8-bit range for the
      first time, though obviously it is system dependent what actual values
      appear in the high order bits retrieved and it may well have been zeros
      in the relevant positions with the system the change originally was
      intended for.  It is at that point that code in `autoconf' should have
      been updated accordingly, but clearly it was overlooked.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org # v2.6.12+
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260516220.37803@angie.orcam.me.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c39c32f
    • Theodore Ts'o's avatar
      ext4: fix potential htree corruption when growing large_dir directories · bc1954aa
      Theodore Ts'o authored
      commit 877ba3f7 upstream.
      
      Commit b5776e75 ("ext4: fix potential htree index checksum
      corruption) removed a required restart when multiple levels of index
      nodes need to be split.  Fix this to avoid directory htree corruptions
      when using the large_dir feature.
      
      Cc: stable@kernel.org # v5.11
      Cc: Благодаренко Артём <artem.blagodarenko@gmail.com>
      Fixes: b5776e75
      
       ("ext4: fix potential htree index checksum corruption)
      Reported-by: default avatarDenis <denis@voxelsoft.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc1954aa
    • Alex Xu (Hello71)'s avatar
      pipe: increase minimum default pipe size to 2 pages · 76ccb26c
      Alex Xu (Hello71) authored
      commit 46c4c9d1 upstream.
      
      This program always prints 4096 and hangs before the patch, and always
      prints 8192 and exits successfully after:
      
        int main()
        {
            int pipefd[2];
            for (int i = 0; i < 1025; i++)
                if (pipe(pipefd) == -1)
                    return 1;
            size_t bufsz = fcntl(pipefd[1], F_GETPIPE_SZ);
            printf("%zd\n", bufsz);
            char *buf = calloc(bufsz, 1);
            write(pipefd[1], buf, bufsz);
            read(pipefd[0], buf, bufsz-1);
            write(pipefd[1], buf, 1);
        }
      
      Note that you may need to increase your RLIMIT_NOFILE before running the
      program.
      
      Fixes: 759c0114
      
       ("pipe: limit the per-user amount of pages allocated in pipes")
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/
      Link: https://lore.kernel.org/lkml/1628127094.lxxn016tj7.none@localhost/
      Signed-off-by: default avatarAlex Xu (Hello71) <alex_y_xu@yahoo.ca>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76ccb26c
    • Johan Hovold's avatar
      media: rtl28xxu: fix zero-length control request · 51f990c7
      Johan Hovold authored
      commit 76f22c93
      
       upstream.
      
      The direction of the pipe argument must match the request-type direction
      bit or control requests may fail depending on the host-controller-driver
      implementation.
      
      Control transfers without a data stage are treated as OUT requests by
      the USB stack and should be using usb_sndctrlpipe(). Failing to do so
      will now trigger a warning.
      
      The driver uses a zero-length i2c-read request for type detection so
      update the control-request code to use usb_sndctrlpipe() in this case.
      
      Note that actually trying to read the i2c register in question does not
      work as the register might not exist (e.g. depending on the demodulator)
      as reported by Eero Lehtinen <debiangamer2@gmail.com>.
      
      Reported-by: default avatar <syzbot+faf11bbadc5a372564da@syzkaller.appspotmail.com>
      Reported-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Tested-by: default avatarEero Lehtinen <debiangamer2@gmail.com>
      Fixes: d0f232e8
      
       ("[media] rtl28xxu: add heuristic to detect chip type")
      Cc: stable@vger.kernel.org      # 4.0
      Cc: Antti Palosaari <crope@iki.fi>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51f990c7
    • Xiangyang Zhang's avatar
      staging: rtl8723bs: Fix a resource leak in sd_int_dpc · ef757e5b
      Xiangyang Zhang authored
      commit 990e4ad3 upstream.
      
      The "c2h_evt" variable is not freed when function call
      "c2h_evt_read_88xx" failed
      
      Fixes: 554c0a3a
      
       ("staging: Add rtl8723bs sdio wifi driver")
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarXiangyang Zhang <xyz.sun.ok@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210628152239.5475-1-xyz.sun.ok@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef757e5b
    • Tyler Hicks's avatar
      optee: Clear stale cache entries during initialization · 78264dfb
      Tyler Hicks authored
      commit b5c10dd0
      
       upstream.
      
      The shm cache could contain invalid addresses if
      optee_disable_shm_cache() was not called from the .shutdown hook of the
      previous kernel before a kexec. These addresses could be unmapped or
      they could point to mapped but unintended locations in memory.
      
      Clear the shared memory cache, while being careful to not translate the
      addresses returned from OPTEE_SMC_DISABLE_SHM_CACHE, during driver
      initialization. Once all pre-cache shm objects are removed, proceed with
      enabling the cache so that we know that we can handle cached shm objects
      with confidence later in the .shutdown hook.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTyler Hicks <tyhicks@linux.microsoft.com>
      Reviewed-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Reviewed-by: default avatarSumit Garg <sumit.garg@linaro.org>
      Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      78264dfb
    • Steven Rostedt (VMware)'s avatar
      tracing/histogram: Rename "cpu" to "common_cpu" · c0add455
      Steven Rostedt (VMware) authored
      commit 1e3bac71 upstream.
      
      Currently the histogram logic allows the user to write "cpu" in as an
      event field, and it will record the CPU that the event happened on.
      
      The problem with this is that there's a lot of events that have "cpu"
      as a real field, and using "cpu" as the CPU it ran on, makes it
      impossible to run histograms on the "cpu" field of events.
      
      For example, if I want to have a histogram on the count of the
      workqueue_queue_work event on its cpu field, running:
      
       ># echo 'hist:keys=cpu' > events/workqueue/workqueue_queue_work/trigger
      
      Gives a misleading and wrong result.
      
      Change the command to "common_cpu" as no event should have "common_*"
      fields as that's a reserved name for fields used by all events. And
      this makes sense here as common_cpu would be a field used by all events.
      
      Now we can even do:
      
       ># echo 'hist:keys=common_cpu,cpu if cpu < 100' > events/workqueue/workqueue_queue_work/trigger
       ># cat events/workqueue/workqueue_queue_work/hist
       # event histogram
       #
       # trigger info: hist:keys=common_cpu,cpu:vals=hitcount:sort=hitcount:size=2048 if cpu < 100 [active]
       #
      
       { common_cpu:          0, cpu:          2 } hitcount:          1
       { common_cpu:          0, cpu:          4 } hitcount:          1
       { common_cpu:          7, cpu:          7 } hitcount:          1
       { common_cpu:          0, cpu:          7 } hitcount:          1
       { common_cpu:          0, cpu:          1 } hitcount:          1
       { common_cpu:          0, cpu:          6 } hitcount:          2
       { common_cpu:          0, cpu:          5 } hitcount:          2
       { common_cpu:          1, cpu:          1 } hitcount:          4
       { common_cpu:          6, cpu:          6 } hitcount:          4
       { common_cpu:          5, cpu:          5 } hitcount:         14
       { common_cpu:          4, cpu:          4 } hitcount:         26
       { common_cpu:          0, cpu:          0 } hitcount:         39
       { common_cpu:          2, cpu:          2 } hitcount:        184
      
      Now for backward compatibility, I added a trick. If "cpu" is used, and
      the field is not found, it will fall back to "common_cpu" and work as
      it did before. This way, it will still work for old programs that use
      "cpu" to get the actual CPU, but if the event has a "cpu" as a field, it
      will get that event's "cpu" field, which is probably what it wants
      anyway.
      
      I updated the tracefs/README to include documentation about both the
      common_timestamp and the common_cpu. This way, if that text is present in
      the README, then an application can know that common_cpu is supported over
      just plain "cpu".
      
      Link: https://lkml.kernel.org/r/20210721110053.26b4f641@oasis.local.home
      
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Fixes: 8b7622bf
      
       ("tracing: Add cpu field for hist triggers")
      Reviewed-by: default avatarTom Zanussi <zanussi@kernel.org>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0add455
    • Steven Rostedt (VMware)'s avatar
      tracing / histogram: Give calculation hist_fields a size · 43cba13f
      Steven Rostedt (VMware) authored
      commit 2c05caa7 upstream.
      
      When working on my user space applications, I found a bug in the synthetic
      event code where the automated synthetic event field was not matching the
      event field calculation it was attached to. Looking deeper into it, it was
      because the calculation hist_field was not given a size.
      
      The synthetic event fields are matched to their hist_fields either by
      having the field have an identical string type, or if that does not match,
      then the size and signed values are used to match the fields.
      
      The problem arose when I tried to match a calculation where the fields
      were "unsigned int". My tool created a synthetic event of type "u32". But
      it failed to match. The string was:
      
        diff=field1-field2:onmatch(event).trace(synth,$diff)
      
      Adding debugging into the kernel, I found that the size of "diff" was 0.
      And since it was given "unsigned int" as a type, the histogram fallback
      code used size and signed. The signed matched, but the size of u32 (4) did
      not match zero, and the event failed to be created.
      
      This can be worse if the field you want to match is not one of the
      acceptable fields for a synthetic event. As event fields can have any type
      that is supported in Linux, this can cause an issue. For example, if a
      type is an enum. Then there's no way to use that with any calculations.
      
      Have the calculation field simply take on the size of what it is
      calculating.
      
      Link: https://lkml.kernel.org/r/20210730171951.59c7743f@oasis.local.home
      
      Cc: Tom Zanussi <zanussi@kernel.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Fixes: 100719dc
      
       ("tracing: Add simple expression support to hist triggers")
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43cba13f
    • Hui Su's avatar
      scripts/tracing: fix the bug that can't parse raw_trace_func · 2ee3c5f1
      Hui Su authored
      commit 1c0cec64 upstream.
      
      Since commit 77271ce4 ("tracing: Add irq, preempt-count and need resched info
      to default trace output"), the default trace output format has been changed to:
                <idle>-0       [009] d.h. 22420.068695: _raw_spin_lock_irqsave <-hrtimer_interrupt
                <idle>-0       [000] ..s. 22420.068695: _nohz_idle_balance <-run_rebalance_domains
                <idle>-0       [011] d.h. 22420.068695: account_process_tick <-update_process_times
      
      origin trace output format:(before v3.2.0)
           # tracer: nop
           #
           #           TASK-PID    CPU#    TIMESTAMP  FUNCTION
           #              | |       |          |         |
                migration/0-6     [000]    50.025810: rcu_note_context_switch <-__schedule
                migration/0-6     [000]    50.025812: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025813: rcu_sched_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025815: rcu_preempt_qs <-rcu_note_context_switch
                migration/0-6     [000]    50.025817: trace_rcu_utilization <-rcu_note_context_switch
                migration/0-6     [000]    50.025818: debug_lockdep_rcu_enabled <-__schedule
                migration/0-6     [000]    50.025820: debug_lockdep_rcu_enabled <-__schedule
      
      The draw_functrace.py(introduced in v2.6.28) can't parse the new version format trace_func,
      So we need modify draw_functrace.py to adapt the new version trace output format.
      
      Link: https://lkml.kernel.org/r/20210611022107.608787-1-suhui@zeku.com
      
      Cc: stable@vger.kernel.org
      Fixes: 77271ce4
      
       tracing: Add irq, preempt-count and need resched info to default trace output
      Signed-off-by: default avatarHui Su <suhui@zeku.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ee3c5f1
    • Dmitry Osipenko's avatar
      usb: otg-fsm: Fix hrtimer list corruption · 4549564c
      Dmitry Osipenko authored
      commit bf88fef0
      
       upstream.
      
      The HNP work can be re-scheduled while it's still in-fly. This results in
      re-initialization of the busy work, resetting the hrtimer's list node of
      the work and crashing kernel with null dereference within kernel/timer
      once work's timer is expired. It's very easy to trigger this problem by
      re-plugging USB cable quickly. Initialize HNP work only once to fix this
      trouble.
      
       Unable to handle kernel NULL pointer dereference at virtual address 00000126)
       ...
       PC is at __run_timers.part.0+0x150/0x228
       LR is at __next_timer_interrupt+0x51/0x9c
       ...
       (__run_timers.part.0) from [<c0187a2b>] (run_timer_softirq+0x2f/0x50)
       (run_timer_softirq) from [<c01013ad>] (__do_softirq+0xd5/0x2f0)
       (__do_softirq) from [<c012589b>] (irq_exit+0xab/0xb8)
       (irq_exit) from [<c0170341>] (handle_domain_irq+0x45/0x60)
       (handle_domain_irq) from [<c04c4a43>] (gic_handle_irq+0x6b/0x7c)
       (gic_handle_irq) from [<c0100b65>] (__irq_svc+0x65/0xac)
      
      Cc: stable@vger.kernel.org
      Acked-by: default avatarPeter Chen <peter.chen@kernel.org>
      Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
      Link: https://lore.kernel.org/r/20210717182134.30262-6-digetx@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4549564c
    • Maxim Devaev's avatar
      usb: gadget: f_hid: idle uses the highest byte for duration · 8b575d82
      Maxim Devaev authored
      commit fa20bada upstream.
      
      SET_IDLE value must be shifted 8 bits to the right to get duration.
      This confirmed by USBCV test.
      
      Fixes: afcff6dc
      
       ("usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMaxim Devaev <mdevaev@gmail.com>
      Link: https://lore.kernel.org/r/20210727185800.43796-1-mdevaev@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b575d82
    • Phil Elwell's avatar
      usb: gadget: f_hid: fixed NULL pointer dereference · 1071804c
      Phil Elwell authored
      commit 2867652e
      
       upstream.
      
      Disconnecting and reconnecting the USB cable can lead to crashes
      and a variety of kernel log spam.
      
      The problem was found and reproduced on the Raspberry Pi [1]
      and the original fix was created in Raspberry's own fork [2].
      
      Link: https://github.com/raspberrypi/linux/issues/3870 [1]
      Link: https://github.com/raspberrypi/linux/commit/a6e47d5f4efbd2ea6a0b6565cd2f9b7bb217ded5 [2]
      Signed-off-by: default avatarMaxim Devaev <mdevaev@gmail.com>
      Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210723155928.210019-1-mdevaev@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1071804c
    • Maxim Devaev's avatar
      usb: gadget: f_hid: added GET_IDLE and SET_IDLE handlers · 92bb8520
      Maxim Devaev authored
      commit afcff6dc
      
       upstream.
      
      The USB HID standard declares mandatory support for GET_IDLE and SET_IDLE
      requests for Boot Keyboard. Most hosts can handle their absence, but others
      like some old/strange UEFIs and BIOSes consider this a critical error
      and refuse to work with f_hid.
      
      This primitive implementation of saving and returning idle is sufficient
      to meet the requirements of the standard and these devices.
      
      Acked-by: default avatarFelipe Balbi <balbi@kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarMaxim Devaev <mdevaev@gmail.com>
      Link: https://lore.kernel.org/r/20210721180351.129450-1-mdevaev@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      92bb8520
    • Alexander Tsoy's avatar
      ALSA: usb-audio: Add registration quirk for JBL Quantum 600 · 6d55383c
      Alexander Tsoy authored
      commit 4b0556b9
      
       upstream.
      
      Apparently JBL Quantum 600 has multiple hardware revisions. Apply
      registration quirk to another device id as well.
      
      Signed-off-by: default avatarAlexander Tsoy <alexander@tsoy.me>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210727093326.1153366-1-alexander@tsoy.me
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d55383c
    • Anirudh Rayabharam's avatar
      firmware_loader: fix use-after-free in firmware_fallback_sysfs · 67cf0fbc
      Anirudh Rayabharam authored
      commit 75d95e2e upstream.
      
      This use-after-free happens when a fw_priv object has been freed but
      hasn't been removed from the pending list (pending_fw_head). The next
      time fw_load_sysfs_fallback tries to insert into the list, it ends up
      accessing the pending_list member of the previously freed fw_priv.
      
      The root cause here is that all code paths that abort the fw load
      don't delete it from the pending list. For example:
      
              _request_firmware()
                -> fw_abort_batch_reqs()
                    -> fw_state_aborted()
      
      To fix this, delete the fw_priv from the list in __fw_set_state() if
      the new state is DONE or ABORTED. This way, all aborts will remove
      the fw_priv from the list. Accordingly, remove calls to list_del_init
      that were being made before calling fw_state_(aborted|done).
      
      Also, in fw_load_sysfs_fallback, don't add the fw_priv to the pending
      list if it is already aborted. Instead, just jump out and return early.
      
      Fixes: bcfbd352
      
       ("firmware: fix a double abort case with fw_load_sysfs_fallback")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatar <syzbot+de271708674e2093097b@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+de271708674e2093097b@syzkaller.appspotmail.com>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarAnirudh Rayabharam <mail@anirudhrb.com>
      Link: https://lore.kernel.org/r/20210728085107.4141-3-mail@anirudhrb.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67cf0fbc
    • Anirudh Rayabharam's avatar
      firmware_loader: use -ETIMEDOUT instead of -EAGAIN in fw_load_sysfs_fallback · ce699ac0
      Anirudh Rayabharam authored
      commit 0d6434e1 upstream.
      
      The only motivation for using -EAGAIN in commit 0542ad88
      
      
      ("firmware loader: Fix _request_firmware_load() return val for fw load
      abort") was to distinguish the error from -ENOMEM, and so there is no
      real reason in keeping it. -EAGAIN is typically used to tell the
      userspace to try something again and in this case re-using the sysfs
      loading interface cannot be retried when a timeout happens, so the
      return value is also bogus.
      
      -ETIMEDOUT is received when the wait times out and returning that
      is much more telling of what the reason for the failure was. So, just
      propagate that instead of returning -EAGAIN.
      
      Suggested-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarAnirudh Rayabharam <mail@anirudhrb.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210728085107.4141-2-mail@anirudhrb.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce699ac0
    • David Bauer's avatar
      USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2 · c660c337
      David Bauer authored
      commit 8da0e55c
      
       upstream.
      
      The Auto-M3 OP-COM v2 is a OBD diagnostic device using a FTD232 for the
      USB connection.
      
      Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c660c337
    • Willy Tarreau's avatar
      USB: serial: ch341: fix character loss at high transfer rates · d5008c3e
      Willy Tarreau authored
      commit 3c18e9ba
      
       upstream.
      
      The chip supports high transfer rates, but with the small default buffers
      (64 bytes read), some entire blocks are regularly lost. This typically
      happens at 1.5 Mbps (which is the default speed on Rockchip devices) when
      used as a console to access U-Boot where the output of the "help" command
      misses many lines and where "printenv" mangles the environment.
      
      The FTDI driver doesn't suffer at all from this. One difference is that
      it uses 512 bytes rx buffers and 256 bytes tx buffers. Adopting these
      values completely resolved the issue, even the output of "dmesg" is
      reliable. I preferred to leave the Tx value unchanged as it is not
      involved in this issue, while a change could increase the risk of
      triggering the same issue with other devices having too small buffers.
      
      I verified that it backports well (and works) at least to 5.4. It's of
      low importance enough to be dropped where it doesn't trivially apply
      anymore.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
      Link: https://lore.kernel.org/r/20210724152739.18726-1-w@1wt.eu
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5008c3e
    • Daniele Palmas's avatar
      USB: serial: option: add Telit FD980 composition 0x1056 · 67a37716
      Daniele Palmas authored
      commit 5648c073
      
       upstream.
      
      Add the following Telit FD980 composition 0x1056:
      
      Cfg #1: mass storage
      Cfg #2: rndis, tty, adb, tty, tty, tty, tty
      
      Signed-off-by: default avatarDaniele Palmas <dnlplm@gmail.com>
      Link: https://lore.kernel.org/r/20210803194711.3036-1-dnlplm@gmail.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67a37716
    • Qiang.zhang's avatar
      USB: usbtmc: Fix RCU stall warning · 08433a2b
      Qiang.zhang authored
      commit 30fad76c upstream.
      
      rcu: INFO: rcu_preempt self-detected stall on CPU
      rcu:    1-...!: (2 ticks this GP) idle=d92/1/0x4000000000000000
              softirq=25390/25392 fqs=3
              (t=12164 jiffies g=31645 q=43226)
      rcu: rcu_preempt kthread starved for 12162 jiffies! g31645 f0x0
           RCU_GP_WAIT_FQS(5) ->state=0x0 ->cpu=0
      rcu:    Unless rcu_preempt kthread gets sufficient CPU time,
              OOM is now expected behavior.
      rcu: RCU grace-period kthread stack dump:
      task:rcu_preempt     state:R  running task
      ...........
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: unknown status received: -71
      usbtmc 3-1:0.0: usb_submit_urb failed: -19
      
      The function usbtmc_interrupt() resubmits urbs when the error status
      of an urb is -EPROTO. In systems using the dummy_hcd usb controller
      this can result in endless interrupt loops when the usbtmc device is
      disconnected from the host system.
      
      Since host controller drivers already try to recover from transmission
      errors, there is no need to resubmit the urb or try other solutions
      to repair the error situation.
      
      In case of errors the INT pipe just stops to wait for further packets.
      
      Fixes: dbf3e7f6
      
       ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation")
      Cc: stable@vger.kernel.org
      Reported-by: default avatar <syzbot+e2eae5639e7203360018@syzkaller.appspotmail.com>
      Signed-off-by: default avatarQiang.zhang <qiang.zhang@windriver.com>
      Acked-by: default avatarGuido Kiener <guido.kiener@rohde-schwarz.com>
      Link: https://lore.kernel.org/r/20210723004334.458930-1-qiang.zhang@windriver.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08433a2b
    • Tetsuo Handa's avatar
      Bluetooth: defer cleanup of resources in hci_unregister_dev() · 3719acc1
      Tetsuo Handa authored
      [ Upstream commit e0448092 ]
      
      syzbot is hitting might_sleep() warning at hci_sock_dev_event() due to
      calling lock_sock() with rw spinlock held [1].
      
      It seems that history of this locking problem is a trial and error.
      
      Commit b40df574 ("[PATCH] bluetooth: fix socket locking in
      hci_sock_dev_event()") in 2.6.21-rc4 changed bh_lock_sock() to
      lock_sock() as an attempt to fix lockdep warning.
      
      Then, commit 4ce61d1c ("[BLUETOOTH]: Fix locking in
      hci_sock_dev_event().") in 2.6.22-rc2 changed lock_sock() to
      local_bh_disable() + bh_lock_sock_nested() as an attempt to fix the
      sleep in atomic context warning.
      
      Then, commit 4b5dd696 ("Bluetooth: Remove local_bh_disable() from
      hci_sock.c") in 3.3-rc1 removed local_bh_disable().
      
      Then, commit e305509e
      
       ("Bluetooth: use correct lock to prevent UAF
      of hdev object") in 5.13-rc5 again changed bh_lock_sock_nested() to
      lock_sock() as an attempt to fix CVE-2021-3573.
      
      This difficulty comes from current implementation that
      hci_sock_dev_event(HCI_DEV_UNREG) is responsible for dropping all
      references from sockets because hci_unregister_dev() immediately
      reclaims resources as soon as returning from
      hci_sock_dev_event(HCI_DEV_UNREG).
      
      But the history suggests that hci_sock_dev_event(HCI_DEV_UNREG) was not
      doing what it should do.
      
      Therefore, instead of trying to detach sockets from device, let's accept
      not detaching sockets from device at hci_sock_dev_event(HCI_DEV_UNREG),
      by moving actual cleanup of resources from hci_unregister_dev() to
      hci_cleanup_dev() which is called by bt_host_release() when all
      references to this unregistered device (which is a kobject) are gone.
      
      Since hci_sock_dev_event(HCI_DEV_UNREG) no longer resets
      hci_pi(sk)->hdev, we need to check whether this device was unregistered
      and return an error based on HCI_UNREGISTER flag.  There might be subtle
      behavioral difference in "monitor the hdev" functionality; please report
      if you found something went wrong due to this patch.
      
      Link: https://syzkaller.appspot.com/bug?extid=a5df189917e79d5e59c9 [1]
      Reported-by: default avatarsyzbot <syzbot+a5df189917e79d5e59c9@syzkaller.appspotmail.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Fixes: e305509e
      
       ("Bluetooth: use correct lock to prevent UAF of hdev object")
      Acked-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3719acc1
    • Yu Kuai's avatar
      blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() · 76ab02d9
      Yu Kuai authored
      [ Upstream commit 8d75d0ef ]
      
      If queue is dying while iolatency_set_limit() is in progress,
      blk_get_queue() won't increment the refcount of the queue. However,
      blk_put_queue() will still decrement the refcount later, which will
      cause the refcout to be unbalanced.
      
      Thus error out in such case to fix the problem.
      
      Fixes: 8c772a9b
      
       ("blk-iolatency: fix IO hang due to negative inflight counter")
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Link: https://lore.kernel.org/r/20210805124645.543797-1-yukuai3@huawei.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      76ab02d9
    • Pavel Skripkin's avatar
      net: vxge: fix use-after-free in vxge_device_unregister · 92c8d9ae
      Pavel Skripkin authored
      [ Upstream commit 942e560a ]
      
      Smatch says:
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3518 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      drivers/net/ethernet/neterion/vxge/vxge-main.c:3520 vxge_device_unregister() error: Using vdev after free_{netdev,candev}(dev);
      
      Since vdev pointer is netdev private data accessing it after free_netdev()
      call can cause use-after-free bug. Fix it by moving free_netdev() call at
      the end of the function
      
      Fixes: 6cca2003
      
       ("vxge: cleanup probe error paths")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      92c8d9ae
    • Pavel Skripkin's avatar
      net: fec: fix use-after-free in fec_drv_remove · bfee67c4
      Pavel Skripkin authored
      [ Upstream commit 44712965
      
       ]
      
      Smatch says:
      	drivers/net/ethernet/freescale/fec_main.c:3994 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);
      	drivers/net/ethernet/freescale/fec_main.c:3995 fec_drv_remove() error: Using fep after free_{netdev,candev}(ndev);
      
      Since fep pointer is netdev private data, accessing it after free_netdev()
      call can cause use-after-free bug. Fix it by moving free_netdev() call at
      the end of the function
      
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Fixes: a31eda65
      
       ("net: fec: fix clock count mis-match")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bfee67c4
    • Pavel Skripkin's avatar
      net: pegasus: fix uninit-value in get_interrupt_interval · 423cbae7
      Pavel Skripkin authored
      [ Upstream commit af35fc37
      
       ]
      
      Syzbot reported uninit value pegasus_probe(). The problem was in missing
      error handling.
      
      get_interrupt_interval() internally calls read_eprom_word() which can
      fail in some cases. For example: failed to receive usb control message.
      These cases should be handled to prevent uninit value bug, since
      read_eprom_word() will not initialize passed stack variable in case of
      internal failure.
      
      Fail log:
      
      BUG: KMSAN: uninit-value in get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
      BUG: KMSAN: uninit-value in pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      CPU: 1 PID: 825 Comm: kworker/1:1 Not tainted 5.12.0-rc6-syzkaller #0
      ...
      Workqueue: usb_hub_wq hub_event
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x24c/0x2e0 lib/dump_stack.c:120
       kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x5c/0xa0 mm/kmsan/kmsan_instr.c:197
       get_interrupt_interval drivers/net/usb/pegasus.c:746 [inline]
       pegasus_probe+0x10e7/0x4080 drivers/net/usb/pegasus.c:1152
      ....
      
      Local variable ----data.i@pegasus_probe created at:
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
       get_interrupt_interval drivers/net/usb/pegasus.c:1151 [inline]
       pegasus_probe+0xe57/0x4080 drivers/net/usb/pegasus.c:1152
      
      Reported-and-tested-by: default avatar <syzbot+02c9f70f3afae308464a@syzkaller.appspotmail.com>
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Link: https://lore.kernel.org/r/20210804143005.439-1-paskripkin@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      423cbae7
    • Dan Carpenter's avatar
      bnx2x: fix an error code in bnx2x_nic_load() · 836e2fd2
      Dan Carpenter authored
      [ Upstream commit fb653827 ]
      
      Set the error code if bnx2x_alloc_fw_stats_mem() fails.  The current
      code returns success.
      
      Fixes: ad5afc89
      
       ("bnx2x: Separate VF and PF logic")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      836e2fd2
    • H. Nikolaus Schaller's avatar
      mips: Fix non-POSIX regexp · 273a3890
      H. Nikolaus Schaller authored
      [ Upstream commit 28bbbb98 ]
      
      When cross compiling a MIPS kernel on a BSD based HOSTCC leads
      to errors like
      
        SYNC    include/config/auto.conf.cmd - due to: .config
      egrep: empty (sub)expression
        UPD     include/config/kernel.release
        HOSTCC  scripts/dtc/dtc.o - due to target missing
      
      It turns out that egrep uses this egrep pattern:
      
      		(|MINOR_|PATCHLEVEL_)
      
      This is not valid syntax or gives undefined results according
      to POSIX 9.5.3 ERE Grammar
      
      	https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html
      
      It seems to be silently accepted by the Linux egrep implementation
      while a BSD host complains.
      
      Such patterns can be replaced by a transformation like
      
      	"(|p1|p2)" -> "(p1|p2)?"
      
      Fixes: 48c35b2d
      
       ("[MIPS] There is no __GNUC_MAJOR__")
      Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      273a3890
    • Antoine Tenart's avatar
      net: ipv6: fix returned variable type in ip6_skb_dst_mtu · 08882fba
      Antoine Tenart authored
      [ Upstream commit 40391467 ]
      
      The patch fixing the returned value of ip6_skb_dst_mtu (int -> unsigned
      int) was rebased between its initial review and the version applied. In
      the meantime fade5641 was applied, which added a new variable (int)
      used as the returned value. This lead to a mismatch between the function
      prototype and the variable used as the return value.
      
      Fixes: 40fc3054
      
       ("net: ipv6: fix return value of ip6_skb_dst_mtu")
      Cc: Vadim Fedorenko <vfedorenko@novek.ru>
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      08882fba
    • Fei Qin's avatar
      nfp: update ethtool reporting of pauseframe control · 264216f8
      Fei Qin authored
      [ Upstream commit 9fdc5d85 ]
      
      Pauseframe control is set to symmetric mode by default on the NFP.
      Pause frames can not be configured through ethtool now, but ethtool can
      report the supported mode.
      
      Fixes: 265aeb51
      
       ("nfp: add support for .get_link_ksettings()")
      Signed-off-by: default avatarFei Qin <fei.qin@corigine.com>
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      264216f8
    • Xin Long's avatar
      sctp: move the active_key update after sh_keys is added · f91e7bd9
      Xin Long authored
      [ Upstream commit ae954bbc ]
      
      In commit 58acd100 ("sctp: update active_key for asoc when old key is
      being replaced"), sctp_auth_asoc_init_active_key() is called to update
      the active_key right after the old key is deleted and before the new key
      is added, and it caused that the active_key could be found with the key_id.
      
      In Ying Xu's testing, the BUG_ON in sctp_auth_asoc_init_active_key() was
      triggered:
      
        [ ] kernel BUG at net/sctp/auth.c:416!
        [ ] RIP: 0010:sctp_auth_asoc_init_active_key.part.8+0xe7/0xf0 [sctp]
        [ ] Call Trace:
        [ ]  sctp_auth_set_key+0x16d/0x1b0 [sctp]
        [ ]  sctp_setsockopt.part.33+0x1ba9/0x2bd0 [sctp]
        [ ]  __sys_setsockopt+0xd6/0x1d0
        [ ]  __x64_sys_setsockopt+0x20/0x30
        [ ]  do_syscall_64+0x5b/0x1a0
      
      So fix it by moving the active_key update after sh_keys is added.
      
      Fixes: 58acd100
      
       ("sctp: update active_key for asoc when old key is being replaced")
      Reported-by: default avatarYing Xu <yinxu@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f91e7bd9
    • Wang Hai's avatar
      net: natsemi: Fix missing pci_disable_device() in probe and remove · 9309cd08
      Wang Hai authored
      [ Upstream commit 7fe74dfd ]
      
      Replace pci_enable_device() with pcim_enable_device(),
      pci_disable_device() and pci_release_regions() will be
      called in release automatically.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9309cd08
    • Hans Verkuil's avatar
      media: videobuf2-core: dequeue if start_streaming fails · a351cafd
      Hans Verkuil authored
      [ Upstream commit c592b469
      
       ]
      
      If a vb2_queue sets q->min_buffers_needed then when the number of
      queued buffers reaches q->min_buffers_needed, vb2_core_qbuf() will call
      the start_streaming() callback. If start_streaming() returns an error,
      then that error was just returned by vb2_core_qbuf(), but the buffer
      was still queued. However, userspace expects that if VIDIOC_QBUF fails,
      the buffer is returned dequeued.
      
      So if start_streaming() fails, then remove the buffer from the queue,
      thus avoiding this unwanted side-effect.
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Tested-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      Fixes: b3379c62
      
       ("[media] vb2: only call start_streaming if sufficient buffers are queued")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a351cafd
    • Li Manyi's avatar
      scsi: sr: Return correct event when media event code is 3 · 489492b5
      Li Manyi authored
      [ Upstream commit 5c04243a ]
      
      Media event code 3 is defined in the MMC-6 spec as follows:
      
        "MediaRemoval: The media has been removed from the specified slot, and
         the Drive is unable to access the media without user intervention. This
         applies to media changers only."
      
      This indicated that treating the condition as an EJECT_REQUEST was
      appropriate. However, doing so had the unfortunate side-effect of causing
      the drive tray to be physically ejected on resume. Instead treat the event
      as a MEDIA_CHANGE request.
      
      Fixes: 7dd753ca
      
       ("scsi: sr: Return appropriate error code when disk is ejected")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=213759
      Link: https://lore.kernel.org/r/20210726114913.6760-1-limanyi@uniontech.com
      Signed-off-by: default avatarLi Manyi <limanyi@uniontech.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      489492b5
    • H. Nikolaus Schaller's avatar
      omap5-board-common: remove not physically existing vdds_1v8_main fixed-regulator · a6af9385
      H. Nikolaus Schaller authored
      [ Upstream commit c68ef4ad ]
      
      This device tree include file describes a fixed-regulator
      connecting smps7_reg output (1.8V) to some 1.8V rail and
      consumers (vdds_1v8_main).
      
      This regulator does not physically exist.
      
      I assume it was introduced as a wrapper around smps7_reg
      to provide a speaking signal name "vdds_1v8_main" as label.
      
      This fixed-regulator without real function was not an issue
      in driver code until
      
        Commit 98e48cd9 ("regulator: core: resolve supply for boot-on/always-on regulators")
      
      introduced a new check for regulator initialization which
      makes Palmas regulator registration fail:
      
      [    5.407712] ldo1: supplied by vsys_cobra
      [    5.412748] ldo2: supplied by vsys_cobra
      [    5.417603] palmas-pmic 48070000.i2c:palmas@48:palmas_pmic: failed to register 48070000.i2c:palmas@48:palmas_pmic regulator
      
      The reason is that the supply-chain of regulators is too
      long and goes from ldo3 through the virtual vdds_1v8_main
      regulator and then back to smps7. This adds a cross-dependency
      of probing Palmas regulators and the fixed-regulator which
      leads to probe deferral by the new check and is no longer
      resolved.
      
      Since we do not control what device tree files including this
      one reference (either &vdds_1v8_main or &smps7_reg or both)
      we keep both labels for smps7 for compatibility.
      
      Fixes: 98e48cd9
      
       ("regulator: core: resolve supply for boot-on/always-on regulators")
      Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a6af9385
    • Dario Binacchi's avatar
      clk: stm32f4: fix post divisor setup for I2S/SAI PLLs · 82ff713e
      Dario Binacchi authored
      [ Upstream commit 24b5b197 ]
      
      Enabling the framebuffer leads to a system hang. Running, as a debug
      hack, the store_pan() function in drivers/video/fbdev/core/fbsysfs.c
      without taking the console_lock, allows to see the crash backtrace on
      the serial line.
      
      ~ # echo 0 0 > /sys/class/graphics/fb0/pan
      
      [    9.719414] Unhandled exception: IPSR = 00000005 LR = fffffff1
      [    9.726937] CPU: 0 PID: 49 Comm: sh Not tainted 5.13.0-rc5 #9
      [    9.733008] Hardware name: STM32 (Device Tree Support)
      [    9.738296] PC is at clk_gate_is_enabled+0x0/0x28
      [    9.743426] LR is at stm32f4_pll_div_set_rate+0xf/0x38
      [    9.748857] pc : [<0011e4be>]    lr : [<0011f9e3>]    psr: 0100000b
      [    9.755373] sp : 00bc7be0  ip : 00000000  fp : 001f3ac4
      [    9.760812] r10: 002610d0  r9 : 01efe920  r8 : 00540560
      [    9.766269] r7 : 02e7ddb0  r6 : 0173eed8  r5 : 00000000  r4 : 004027c0
      [    9.773081] r3 : 0011e4bf  r2 : 02e7ddb0  r1 : 0173eed8  r0 : 1d3267b8
      [    9.779911] xPSR: 0100000b
      [    9.782719] CPU: 0 PID: 49 Comm: sh Not tainted 5.13.0-rc5 #9
      [    9.788791] Hardware name: STM32 (Device Tree Support)
      [    9.794120] [<0000afa1>] (unwind_backtrace) from [<0000a33f>] (show_stack+0xb/0xc)
      [    9.802421] [<0000a33f>] (show_stack) from [<0000a8df>] (__invalid_entry+0x4b/0x4c)
      
      The `pll_num' field in the post_div_data configuration contained a wrong
      value which also referenced an uninitialized hardware clock when
      clk_register_pll_div() was called.
      
      Fixes: 517633ef
      
       ("clk: stm32f4: Add post divisor for I2S & SAI PLLs")
      Signed-off-by: default avatarDario Binacchi <dariobin@libero.it>
      Reviewed-by: default avatarGabriel Fernandez <gabriel.fernandez@st.com>
      Link: https://lore.kernel.org/r/20210725160725.10788-1-dariobin@libero.it
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      82ff713e