commit 650093916eb3140339a3132ef7d5a02d8712d058
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Dec 8 11:30:22 2022 +0100

    Linux 6.0.12
    
    Link: https://lore.kernel.org/r/20221205190808.422385173@linuxfoundation.org
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Fenil Jain <fkjainco@gmail.com>
    Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Allen Pais <apais@linux.microsoft.com>
    Link: https://lore.kernel.org/r/20221206124053.847053972@linuxfoundation.org
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Link: https://lore.kernel.org/r/20221206163445.868107856@linuxfoundation.org
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Jon Hunter <jonathanh@nvidia.com>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
    Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fdf2c95f28bf197bfab421d21e8c697d4f149ea1
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Dec 5 12:09:06 2022 -0800

    proc: proc_skip_spaces() shouldn't think it is working on C strings
    
    commit bce9332220bd677d83b19d21502776ad555a0e73 upstream.
    
    proc_skip_spaces() seems to think it is working on C strings, and ends
    up being just a wrapper around skip_spaces() with a really odd calling
    convention.
    
    Instead of basing it on skip_spaces(), it should have looked more like
    proc_skip_char(), which really is the exact same function (except it
    skips a particular character, rather than whitespace).  So use that as
    inspiration, odd coding and all.
    
    Now the calling convention actually makes sense and works for the
    intended purpose.
    
    Reported-and-tested-by: Kyle Zeng <zengyhkyle@gmail.com>
    Acked-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e04220518841708f68e7746232e3e54daef464a3
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Dec 5 11:33:40 2022 -0800

    proc: avoid integer type confusion in get_proc_long
    
    commit e6cfaf34be9fcd1a8285a294e18986bfc41a409c upstream.
    
    proc_get_long() is passed a size_t, but then assigns it to an 'int'
    variable for the length.  Let's not do that, even if our IO paths are
    limited to MAX_RW_COUNT (exactly because of these kinds of type errors).
    
    So do the proper test in the rigth type.
    
    Reported-by: Kyle Zeng <zengyhkyle@gmail.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0641b614d1154f32c0dacecea46aca7460b69e32
Author: Jann Horn <jannh@google.com>
Date:   Mon Dec 5 17:59:27 2022 +0100

    ipc/sem: Fix dangling sem_array access in semtimedop race
    
    commit b52be557e24c47286738276121177a41f54e3b83 upstream.
    
    When __do_semtimedop() goes to sleep because it has to wait for a
    semaphore value becoming zero or becoming bigger than some threshold, it
    links the on-stack sem_queue to the sem_array, then goes to sleep
    without holding a reference on the sem_array.
    
    When __do_semtimedop() comes back out of sleep, one of two things must
    happen:
    
     a) We prove that the on-stack sem_queue has been disconnected from the
        (possibly freed) sem_array, making it safe to return from the stack
        frame that the sem_queue exists in.
    
     b) We stabilize our reference to the sem_array, lock the sem_array, and
        detach the sem_queue from the sem_array ourselves.
    
    sem_array has RCU lifetime, so for case (b), the reference can be
    stabilized inside an RCU read-side critical section by locklessly
    checking whether the sem_queue is still connected to the sem_array.
    
    However, the current code does the lockless check on sem_queue before
    starting an RCU read-side critical section, so the result of the
    lockless check immediately becomes useless.
    
    Fix it by doing rcu_read_lock() before the lockless check.  Now RCU
    ensures that if we observe the object being on our queue, the object
    can't be freed until rcu_read_unlock().
    
    This bug is only hittable on kernel builds with full preemption support
    (either CONFIG_PREEMPT or PREEMPT_DYNAMIC with preempt=full).
    
    Fixes: 370b262c896e ("ipc/sem: avoid idr tree lookup for interrupted semop")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 747a6e547240baaaf41874d27333b87b87cfd24c
Author: Christophe Leroy <christophe.leroy@csgroup.eu>
Date:   Thu Nov 24 09:37:27 2022 +0100

    powerpc/bpf/32: Fix Oops on tail call tests
    
    commit 89d21e259a94f7d5582ec675aa445f5a79f347e4 upstream.
    
    test_bpf tail call tests end up as:
    
      test_bpf: #0 Tail call leaf jited:1 85 PASS
      test_bpf: #1 Tail call 2 jited:1 111 PASS
      test_bpf: #2 Tail call 3 jited:1 145 PASS
      test_bpf: #3 Tail call 4 jited:1 170 PASS
      test_bpf: #4 Tail call load/store leaf jited:1 190 PASS
      test_bpf: #5 Tail call load/store jited:1
      BUG: Unable to handle kernel data access on write at 0xf1b4e000
      Faulting instruction address: 0xbe86b710
      Oops: Kernel access of bad area, sig: 11 [#1]
      BE PAGE_SIZE=4K MMU=Hash PowerMac
      Modules linked in: test_bpf(+)
      CPU: 0 PID: 97 Comm: insmod Not tainted 6.1.0-rc4+ #195
      Hardware name: PowerMac3,1 750CL 0x87210 PowerMac
      NIP:  be86b710 LR: be857e88 CTR: be86b704
      REGS: f1b4df20 TRAP: 0300   Not tainted  (6.1.0-rc4+)
      MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 28008242  XER: 00000000
      DAR: f1b4e000 DSISR: 42000000
      GPR00: 00000001 f1b4dfe0 c11d2280 00000000 00000000 00000000 00000002 00000000
      GPR08: f1b4e000 be86b704 f1b4e000 00000000 00000000 100d816a f2440000 fe73baa8
      GPR16: f2458000 00000000 c1941ae4 f1fe2248 00000045 c0de0000 f2458030 00000000
      GPR24: 000003e8 0000000f f2458000 f1b4dc90 3e584b46 00000000 f24466a0 c1941a00
      NIP [be86b710] 0xbe86b710
      LR [be857e88] __run_one+0xec/0x264 [test_bpf]
      Call Trace:
      [f1b4dfe0] [00000002] 0x2 (unreliable)
      Instruction dump:
      XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
      XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX
      ---[ end trace 0000000000000000 ]---
    
    This is a tentative to write above the stack. The problem is encoutered
    with tests added by commit 38608ee7b690 ("bpf, tests: Add load store
    test case for tail call")
    
    This happens because tail call is done to a BPF prog with a different
    stack_depth. At the time being, the stack is kept as is when the caller
    tail calls its callee. But at exit, the callee restores the stack based
    on its own properties. Therefore here, at each run, r1 is erroneously
    increased by 32 - 16 = 16 bytes.
    
    This was done that way in order to pass the tail call count from caller
    to callee through the stack. As powerpc32 doesn't have a red zone in
    the stack, it was necessary the maintain the stack as is for the tail
    call. But it was not anticipated that the BPF frame size could be
    different.
    
    Let's take a new approach. Use register r4 to carry the tail call count
    during the tail call, and save it into the stack at function entry if
    required. This means the input parameter must be in r3, which is more
    correct as it is a 32 bits parameter, then tail call better match with
    normal BPF function entry, the down side being that we move that input
    parameter back and forth between r3 and r4. That can be optimised later.
    
    Doing that also has the advantage of maximising the common parts between
    tail calls and a normal function exit.
    
    With the fix, tail call tests are now successfull:
    
      test_bpf: #0 Tail call leaf jited:1 53 PASS
      test_bpf: #1 Tail call 2 jited:1 115 PASS
      test_bpf: #2 Tail call 3 jited:1 154 PASS
      test_bpf: #3 Tail call 4 jited:1 165 PASS
      test_bpf: #4 Tail call load/store leaf jited:1 101 PASS
      test_bpf: #5 Tail call load/store jited:1 141 PASS
      test_bpf: #6 Tail call error path, max count reached jited:1 994 PASS
      test_bpf: #7 Tail call count preserved across function calls jited:1 140975 PASS
      test_bpf: #8 Tail call error path, NULL target jited:1 110 PASS
      test_bpf: #9 Tail call error path, index out of range jited:1 69 PASS
      test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
    
    Suggested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Fixes: 51c66ad849a7 ("powerpc/bpf: Implement extended BPF on PPC32")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    Tested-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/757acccb7fbfc78efa42dcf3c974b46678198905.1669278887.git.christophe.leroy@csgroup.eu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 097c1c7a28e3da8f2811ba532be6e81faab15aab
Author: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Date:   Fri Dec 2 15:37:46 2022 -0800

    Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()
    
    commit 8c9a59939deb4bfafdc451100c03d1e848b4169b upstream.
    
    There is a kmemleak when test the raydium_i2c_ts with bpf mock device:
    
      unreferenced object 0xffff88812d3675a0 (size 8):
        comm "python3", pid 349, jiffies 4294741067 (age 95.695s)
        hex dump (first 8 bytes):
          11 0e 10 c0 01 00 04 00                          ........
        backtrace:
          [<0000000068427125>] __kmalloc+0x46/0x1b0
          [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
          [<000000006e631aee>] raydium_i2c_initialize.cold+0xbc/0x3e4 [raydium_i2c_ts]
          [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
          [<00000000a310de16>] i2c_device_probe+0x651/0x680
          [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
          [<00000000096ba499>] __driver_probe_device+0xe3/0x170
          [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
          [<00000000264fe082>] __device_attach_driver+0xf7/0x150
          [<00000000f919423c>] bus_for_each_drv+0x114/0x180
          [<00000000e067feca>] __device_attach+0x1e5/0x2d0
          [<0000000054301fc2>] bus_probe_device+0x126/0x140
          [<00000000aad93b22>] device_add+0x810/0x1130
          [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
          [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
          [<00000000ffec4177>] of_i2c_notify+0x100/0x160
      unreferenced object 0xffff88812d3675c8 (size 8):
        comm "python3", pid 349, jiffies 4294741070 (age 95.692s)
        hex dump (first 8 bytes):
          22 00 36 2d 81 88 ff ff                          ".6-....
        backtrace:
          [<0000000068427125>] __kmalloc+0x46/0x1b0
          [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
          [<000000001d5c9620>] raydium_i2c_initialize.cold+0x223/0x3e4 [raydium_i2c_ts]
          [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
          [<00000000a310de16>] i2c_device_probe+0x651/0x680
          [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
          [<00000000096ba499>] __driver_probe_device+0xe3/0x170
          [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
          [<00000000264fe082>] __device_attach_driver+0xf7/0x150
          [<00000000f919423c>] bus_for_each_drv+0x114/0x180
          [<00000000e067feca>] __device_attach+0x1e5/0x2d0
          [<0000000054301fc2>] bus_probe_device+0x126/0x140
          [<00000000aad93b22>] device_add+0x810/0x1130
          [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
          [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
          [<00000000ffec4177>] of_i2c_notify+0x100/0x160
    
    After BANK_SWITCH command from i2c BUS, no matter success or error
    happened, the tx_buf should be freed.
    
    Fixes: 3b384bd6c3f2 ("Input: raydium_ts_i2c - do not split tx transactions")
    Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
    Link: https://lore.kernel.org/r/20221202103412.2120169-1-zhangxiaoxu5@huawei.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 25b78bf98b07ff5aceb9b1e24f72ec0236c5c053
Author: Jan Dabros <jsd@semihalf.com>
Date:   Mon Nov 28 20:56:51 2022 +0100

    char: tpm: Protect tpm_pm_suspend with locks
    
    commit 23393c6461422df5bf8084a086ada9a7e17dc2ba upstream.
    
    Currently tpm transactions are executed unconditionally in
    tpm_pm_suspend() function, which may lead to races with other tpm
    accessors in the system.
    
    Specifically, the hw_random tpm driver makes use of tpm_get_random(),
    and this function is called in a loop from a kthread, which means it's
    not frozen alongside userspace, and so can race with the work done
    during system suspend:
    
      tpm tpm0: tpm_transmit: tpm_recv: error -52
      tpm tpm0: invalid TPM_STS.x 0xff, dumping stack for forensics
      CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc5+ #135
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
      Call Trace:
       tpm_tis_status.cold+0x19/0x20
       tpm_transmit+0x13b/0x390
       tpm_transmit_cmd+0x20/0x80
       tpm1_pm_suspend+0xa6/0x110
       tpm_pm_suspend+0x53/0x80
       __pnp_bus_suspend+0x35/0xe0
       __device_suspend+0x10f/0x350
    
    Fix this by calling tpm_try_get_ops(), which itself is a wrapper around
    tpm_chip_start(), but takes the appropriate mutex.
    
    Signed-off-by: Jan Dabros <jsd@semihalf.com>
    Reported-by: Vlastimil Babka <vbabka@suse.cz>
    Tested-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Tested-by: Vlastimil Babka <vbabka@suse.cz>
    Link: https://lore.kernel.org/all/c5ba47ef-393f-1fba-30bd-1230d1b4b592@suse.cz/
    Cc: stable@vger.kernel.org
    Fixes: e891db1a18bf ("tpm: turn on TPM on suspend for TPM 1.x")
    [Jason: reworked commit message, added metadata]
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5f103ad83b5c77f82313247014e08dd3471edf1b
Author: Conor Dooley <conor.dooley@microchip.com>
Date:   Tue Nov 22 12:16:21 2022 +0000

    Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"
    
    [ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]
    
    This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.
    
    On the subject of suspend, the RISC-V SBI spec states:
    
      This does not cover whether any given events actually reach the hart or
      not, just what the hart will do if it receives an event. On PolarFire
      SoC, and potentially other SiFive based implementations, events from the
      RISC-V timer do reach a hart during suspend. This is not the case for the
      implementation on the Allwinner D1 - there timer events are not received
      during suspend.
    
    To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
    timer driver - but this has broken both RCU stall detection and timers
    generally on PolarFire SoC and potentially other SiFive based
    implementations.
    
    If an AXI read to the PCIe controller on PolarFire SoC times out, the
    system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
    just locks up without RCU stalling:
    
            io scheduler mq-deadline registered
            io scheduler kyber registered
            microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
            microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
            microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: axi read request error
            microchip-pcie 2000000000.pcie: axi read timeout
            microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
            microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
            Freeing initrd memory: 7332K
    
    Similarly issues were reported with clock_nanosleep() - with a test app
    that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
    commit in place, the sleep times are rounded up to the next jiffy:
    
    == CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
    Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
    Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
    Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
    Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
    Samples: 521      Samples: 521      Samples: 521      Samples: 521
    
    Fortunately, the D1 has a second timer, which is "currently used in
    preference to the RISC-V/SBI timer driver" so a revert here does not
    hurt operation of D1 in its current form.
    
    Ultimately, a DeviceTree property (or node) will be added to encode the
    behaviour of the timers, but until then revert the addition of
    CLOCK_EVT_FEAT_C3STOP.
    
    Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
    Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
    Acked-by: Samuel Holland <samuel@sholland.org>
    Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
    Link: https://github.com/riscv-non-isa/riscv-sbi-doc/issues/98/
    Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
    Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 341c662836bb17bb4025c27f19597d3d429678e2
Author: Vishal Verma <vishal.l.verma@intel.com>
Date:   Wed Nov 16 16:37:37 2022 -0700

    ACPI: HMAT: Fix initiator registration for single-initiator systems
    
    [ Upstream commit 48d4180939e12c4bd2846f984436d895bb9699ed ]
    
    In a system with a single initiator node, and one or more memory-only
    'target' nodes, the memory-only node(s) would fail to register their
    initiator node correctly. i.e. in sysfs:
    
      # ls /sys/devices/system/node/node0/access0/targets/
      node0
    
    Where as the correct behavior should be:
    
      # ls /sys/devices/system/node/node0/access0/targets/
      node0 node1
    
    This happened because hmat_register_target_initiators() uses list_sort()
    to sort the initiator list, but the sort comparision function
    (initiator_cmp()) is overloaded to also set the node mask's bits.
    
    In a system with a single initiator, the list is singular, and list_sort
    elides the comparision helper call. Thus the node mask never gets set,
    and the subsequent search for the best initiator comes up empty.
    
    Add a new helper to consume the sorted initiator list, and generate the
    nodemask, decoupling it from the overloaded initiator_cmp() comparision
    callback. This prevents the singular list corner case naturally, and
    makes the code easier to follow as well.
    
    Cc: <stable@vger.kernel.org>
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Cc: Liu Shixin <liushixin2@huawei.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Reported-by: Chris Piper <chris.d.piper@intel.com>
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-2-3712569be691@intel.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9bfbea9e63dc81b4de5f796dc45351a2aba51ede
Author: Vishal Verma <vishal.l.verma@intel.com>
Date:   Wed Nov 16 16:37:36 2022 -0700

    ACPI: HMAT: remove unnecessary variable initialization
    
    [ Upstream commit 14f16d47561ba9249efc6c2db9d47ed56841f070 ]
    
    In hmat_register_target_initiators(), the variable 'best' gets
    initialized in the outer per-locality-type for loop. The initialization
    just before setting up 'Access 1' targets was unnecessary. Remove it.
    
    Cc: Rafael J. Wysocki <rafael@kernel.org>
    Cc: Liu Shixin <liushixin2@huawei.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
    Link: https://lore.kernel.org/r/20221116-acpi_hmat_fix-v2-1-3712569be691@intel.com
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Stable-dep-of: 48d4180939e1 ("ACPI: HMAT: Fix initiator registration for single-initiator systems")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 324ec6eec4befb207a7f1ee84bd3312ecb47ce52
Author: Andrew Lunn <andrew@lunn.ch>
Date:   Thu Nov 10 00:59:02 2022 +0100

    i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
    
    [ Upstream commit d36678f7905cbd1dc55a8a96e066dafd749d4600 ]
    
    Recent changes to the DMA code has resulting in the IMX driver failing
    I2C transfers when the buffer has been vmalloc. Only perform DMA
    transfers if the message has the I2C_M_DMA_SAFE flag set, indicating
    the client is providing a buffer which is DMA safe.
    
    This is a minimal fix for stable. The I2C core provides helpers to
    allocate a bounce buffer. For a fuller fix the master should make use
    of these helpers.
    
    Fixes: 4544b9f25e70 ("dma-mapping: Add vmap checks to dma_map_single()")
    Signed-off-by: Andrew Lunn <andrew@lunn.ch>
    Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2bfc02b81c7824925759dcd6f15e528b8449cf8b
Author: Wang Yufen <wangyufen@huawei.com>
Date:   Mon Nov 21 18:17:52 2022 +0800

    i2c: qcom-geni: fix error return code in geni_i2c_gpi_xfer
    
    [ Upstream commit 7d8ccf4f117d082156e842d959f634efcf203cef ]
    
    Fix to return a negative error code from the gi2c->err instead of
    0.
    
    Fixes: d8703554f4de ("i2c: qcom-geni: Add support for GPI DMA")
    Signed-off-by: Wang Yufen <wangyufen@huawei.com>
    Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasoluitons.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d59abedb88d2f892cc38a0ce21d91671b8ad0a68
Author: Yuan Can <yuancan@huawei.com>
Date:   Wed Nov 9 11:22:50 2022 +0000

    i2c: npcm7xx: Fix error handling in npcm_i2c_init()
    
    [ Upstream commit 145900cf91c4b32ac05dbc8675a0c7f4a278749d ]
    
    A problem about i2c-npcm7xx create debugfs failed is triggered with the
    following log given:
    
     [  173.827310] debugfs: Directory 'npcm_i2c' with parent '/' already present!
    
    The reason is that npcm_i2c_init() returns platform_driver_register()
    directly without checking its return value, if platform_driver_register()
    failed, it returns without destroy the newly created debugfs, resulting
    the debugfs of npcm_i2c can never be created later.
    
     npcm_i2c_init()
       debugfs_create_dir() # create debugfs directory
       platform_driver_register()
         driver_register()
           bus_add_driver()
             priv = kzalloc(...) # OOM happened
       # return without destroy debugfs directory
    
    Fix by removing debugfs when platform_driver_register() returns error.
    
    Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Reviewed-by: Tali Perry <tali.perry@nuvoton.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b6be48100e59cdf236a12868d10479a2797effa1
Author: Ricardo Ribalda <ribalda@chromium.org>
Date:   Mon Nov 14 13:20:34 2022 +0100

    i2c: Restore initial power state if probe fails
    
    commit 79ece9b292af6b0edcfb4d67a00711d25507640b upstream.
    
    A driver that supports I2C_DRV_ACPI_WAIVE_D0_PROBE is not expected to
    power off a device that it has not powered on previously.
    
    For devices operating in "full_power" mode, the first call to
    `i2c_acpi_waive_d0_probe` will return 0, which means that the device
    will be turned on with `dev_pm_domain_attach`.
    
    If probe fails the second call to `i2c_acpi_waive_d0_probe` will
    return 1, which means that the device will not be turned off.
    This is, it will be left in a different power state. Lets fix it.
    
    Reviewed-by: Hidenori Kobayashi <hidenorik@chromium.org>
    Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
    Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Cc: stable@vger.kernel.org
    Fixes: b18c1ad685d9 ("i2c: Allow an ACPI driver to manage the device's power state during probe")
    Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
    Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f98d1f2a36ad7ab48fb4cf73ca14e7b19482fd4d
Author: SeongJae Park <sj@kernel.org>
Date:   Tue Nov 22 19:48:31 2022 +0000

    mm/damon/sysfs: fix wrong empty schemes assumption under online tuning in damon_sysfs_set_schemes()
    
    [ Upstream commit 95bc35f9bee5220dad4e8567654ab3288a181639 ]
    
    Commit da87878010e5 ("mm/damon/sysfs: support online inputs update") made
    'damon_sysfs_set_schemes()' to be called for running DAMON context, which
    could have schemes.  In the case, DAMON sysfs interface is supposed to
    update, remove, or add schemes to reflect the sysfs files.  However, the
    code is assuming the DAMON context wouldn't have schemes at all, and
    therefore creates and adds new schemes.  As a result, the code doesn't
    work as intended for online schemes tuning and could have more than
    expected memory footprint.  The schemes are all in the DAMON context, so
    it doesn't leak the memory, though.
    
    Remove the wrong asssumption (the DAMON context wouldn't have schemes) in
    'damon_sysfs_set_schemes()' to fix the bug.
    
    Link: https://lkml.kernel.org/r/20221122194831.3472-1-sj@kernel.org
    Fixes: da87878010e5 ("mm/damon/sysfs: support online inputs update")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: <stable@vger.kernel.org>    [5.19+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fd3e613a912bbb344ee18579cc2ad3329aacba41
Author: Yajun Deng <yajun.deng@linux.dev>
Date:   Thu Sep 8 19:14:43 2022 +0000

    mm/damon: introduce struct damos_access_pattern
    
    [ Upstream commit f5a79d7c0c87c8d88bb5e3f3c898258fdf1b3b05 ]
    
    damon_new_scheme() has too many parameters, so introduce struct
    damos_access_pattern to simplify it.
    
    In additon, we can't use a bpf trace kprobe that has more than 5
    parameters.
    
    Link: https://lkml.kernel.org/r/20220908191443.129534-1-sj@kernel.org
    Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Reviewed-by: SeongJae Park <sj@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Stable-dep-of: 95bc35f9bee5 ("mm/damon/sysfs: fix wrong empty schemes assumption under online tuning in damon_sysfs_set_schemes()")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 73c9b0d2070d8fe549a5cbb12f06ab60341bfd66
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Thu Nov 24 23:09:32 2022 +0200

    ipv4: Fix route deletion when nexthop info is not specified
    
    [ Upstream commit d5082d386eee7e8ec46fa8581932c81a4961dcef ]
    
    When the kernel receives a route deletion request from user space it
    tries to delete a route that matches the route attributes specified in
    the request.
    
    If only prefix information is specified in the request, the kernel
    should delete the first matching FIB alias regardless of its associated
    FIB info. However, an error is currently returned when the FIB info is
    backed by a nexthop object:
    
     # ip nexthop add id 1 via 192.0.2.2 dev dummy10
     # ip route add 198.51.100.0/24 nhid 1
     # ip route del 198.51.100.0/24
     RTNETLINK answers: No such process
    
    Fix by matching on such a FIB info when legacy nexthop attributes are
    not specified in the request. An earlier check already covers the case
    where a nexthop ID is specified in the request.
    
    Add tests that cover these flows. Before the fix:
    
     # ./fib_nexthops.sh -t ipv4_fcnal
     ...
     TEST: Delete route when not specifying nexthop attributes           [FAIL]
    
     Tests passed:  11
     Tests failed:   1
    
    After the fix:
    
     # ./fib_nexthops.sh -t ipv4_fcnal
     ...
     TEST: Delete route when not specifying nexthop attributes           [ OK ]
    
     Tests passed:  12
     Tests failed:   0
    
    No regressions in other tests:
    
     # ./fib_nexthops.sh
     ...
     Tests passed: 228
     Tests failed:   0
    
     # ./fib_tests.sh
     ...
     Tests passed: 186
     Tests failed:   0
    
    Cc: stable@vger.kernel.org
    Reported-by: Jonas Gorski <jonas.gorski@gmail.com>
    Tested-by: Jonas Gorski <jonas.gorski@gmail.com>
    Fixes: 493ced1ac47c ("ipv4: Allow routes to use nexthop objects")
    Fixes: 6bf92d70e690 ("net: ipv4: fix route with nexthop object delete warning")
    Fixes: 61b91eb33a69 ("ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference")
    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Link: https://lore.kernel.org/r/20221124210932.2470010-1-idosch@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bb20a2ae241be846bc3c11ea4b3a3c69e41d51f2
Author: David Ahern <dsahern@kernel.org>
Date:   Thu Oct 6 10:48:49 2022 -0600

    ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference
    
    [ Upstream commit 61b91eb33a69c3be11b259c5ea484505cd79f883 ]
    
    Gwangun Jung reported a slab-out-of-bounds access in fib_nh_match:
        fib_nh_match+0xf98/0x1130 linux-6.0-rc7/net/ipv4/fib_semantics.c:961
        fib_table_delete+0x5f3/0xa40 linux-6.0-rc7/net/ipv4/fib_trie.c:1753
        inet_rtm_delroute+0x2b3/0x380 linux-6.0-rc7/net/ipv4/fib_frontend.c:874
    
    Separate nexthop objects are mutually exclusive with the legacy
    multipath spec. Fix fib_nh_match to return if the config for the
    to be deleted route contains a multipath spec while the fib_info
    is using a nexthop object.
    
    Fixes: 493ced1ac47c ("ipv4: Allow routes to use nexthop objects")
    Fixes: 6bf92d70e690 ("net: ipv4: fix route with nexthop object delete warning")
    Reported-by: Gwangun Jung <exsociety@gmail.com>
    Signed-off-by: David Ahern <dsahern@kernel.org>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Tested-by: Ido Schimmel <idosch@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Stable-dep-of: d5082d386eee ("ipv4: Fix route deletion when nexthop info is not specified")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2a8f7b90681472948de172dbbf5a54cd342870aa
Author: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date:   Thu Dec 1 12:01:27 2022 +0800

    iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()
    
    [ Upstream commit 4bedbbd782ebbe7287231fea862c158d4f08a9e3 ]
    
    for_each_pci_dev() is implemented by pci_get_device(). The comment of
    pci_get_device() says that it will increase the reference count for the
    returned pci_dev and also decrease the reference count for the input
    pci_dev @from if it is not NULL.
    
    If we break for_each_pci_dev() loop with pdev not NULL, we need to call
    pci_dev_put() to decrease the reference count. Add the missing
    pci_dev_put() for the error path to avoid reference count leak.
    
    Fixes: 2e4552893038 ("iommu/vt-d: Unify the way to process DMAR device scope array")
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Link: https://lore.kernel.org/r/20221121113649.190393-3-wangxiongfeng2@huawei.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 17f67414718e6aba123335a33b7d15aa594fff34
Author: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date:   Thu Dec 1 12:01:26 2022 +0800

    iommu/vt-d: Fix PCI device refcount leak in has_external_pci()
    
    [ Upstream commit afca9e19cc720bfafc75dc5ce429c185ca93f31d ]
    
    for_each_pci_dev() is implemented by pci_get_device(). The comment of
    pci_get_device() says that it will increase the reference count for the
    returned pci_dev and also decrease the reference count for the input
    pci_dev @from if it is not NULL.
    
    If we break for_each_pci_dev() loop with pdev not NULL, we need to call
    pci_dev_put() to decrease the reference count. Add the missing
    pci_dev_put() before 'return true' to avoid reference count leak.
    
    Fixes: 89a6079df791 ("iommu/vt-d: Force IOMMU on for platform opt in hint")
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Link: https://lore.kernel.org/r/20221121113649.190393-2-wangxiongfeng2@huawei.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5b566d09ab1b975566a53f9c5466ee260d087582
Author: Caleb Sander <csander@purestorage.com>
Date:   Fri Nov 18 16:27:56 2022 -0700

    nvme: fix SRCU protection of nvme_ns_head list
    
    [ Upstream commit 899d2a05dc14733cfba6224083c6b0dd5a738590 ]
    
    Walking the nvme_ns_head siblings list is protected by the head's srcu
    in nvme_ns_head_submit_bio() but not nvme_mpath_revalidate_paths().
    Removing namespaces from the list also fails to synchronize the srcu.
    Concurrent scan work can therefore cause use-after-frees.
    
    Hold the head's srcu lock in nvme_mpath_revalidate_paths() and
    synchronize with the srcu, not the global RCU, in nvme_ns_remove().
    
    Observed the following panic when making NVMe/RDMA connections
    with native multipath on the Rocky Linux 8.6 kernel
    (it seems the upstream kernel has the same race condition).
    Disassembly shows the faulting instruction is cmp 0x50(%rdx),%rcx;
    computing capacity != get_capacity(ns->disk).
    Address 0x50 is dereferenced because ns->disk is NULL.
    The NULL disk appears to be the result of concurrent scan work
    freeing the namespace (note the log line in the middle of the panic).
    
    [37314.206036] BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
    [37314.206036] nvme0n3: detected capacity change from 0 to 11811160064
    [37314.299753] PGD 0 P4D 0
    [37314.299756] Oops: 0000 [#1] SMP PTI
    [37314.299759] CPU: 29 PID: 322046 Comm: kworker/u98:3 Kdump: loaded Tainted: G        W      X --------- -  - 4.18.0-372.32.1.el8test86.x86_64 #1
    [37314.299762] Hardware name: Dell Inc. PowerEdge R720/0JP31P, BIOS 2.7.0 05/23/2018
    [37314.299763] Workqueue: nvme-wq nvme_scan_work [nvme_core]
    [37314.299783] RIP: 0010:nvme_mpath_revalidate_paths+0x26/0xb0 [nvme_core]
    [37314.299790] Code: 1f 44 00 00 66 66 66 66 90 55 53 48 8b 5f 50 48 8b 83 c8 c9 00 00 48 8b 13 48 8b 48 50 48 39 d3 74 20 48 8d 42 d0 48 8b 50 20 <48> 3b 4a 50 74 05 f0 80 60 70 ef 48 8b 50 30 48 8d 42 d0 48 39 d3
    [37315.058803] RSP: 0018:ffffabe28f913d10 EFLAGS: 00010202
    [37315.121316] RAX: ffff927a077da800 RBX: ffff92991dd70000 RCX: 0000000001600000
    [37315.206704] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff92991b719800
    [37315.292106] RBP: ffff929a6b70c000 R08: 000000010234cd4a R09: c0000000ffff7fff
    [37315.377501] R10: 0000000000000001 R11: ffffabe28f913a30 R12: 0000000000000000
    [37315.462889] R13: ffff92992716600c R14: ffff929964e6e030 R15: ffff92991dd70000
    [37315.548286] FS:  0000000000000000(0000) GS:ffff92b87fb80000(0000) knlGS:0000000000000000
    [37315.645111] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [37315.713871] CR2: 0000000000000050 CR3: 0000002208810006 CR4: 00000000000606e0
    [37315.799267] Call Trace:
    [37315.828515]  nvme_update_ns_info+0x1ac/0x250 [nvme_core]
    [37315.892075]  nvme_validate_or_alloc_ns+0x2ff/0xa00 [nvme_core]
    [37315.961871]  ? __blk_mq_free_request+0x6b/0x90
    [37316.015021]  nvme_scan_work+0x151/0x240 [nvme_core]
    [37316.073371]  process_one_work+0x1a7/0x360
    [37316.121318]  ? create_worker+0x1a0/0x1a0
    [37316.168227]  worker_thread+0x30/0x390
    [37316.212024]  ? create_worker+0x1a0/0x1a0
    [37316.258939]  kthread+0x10a/0x120
    [37316.297557]  ? set_kthread_struct+0x50/0x50
    [37316.347590]  ret_from_fork+0x35/0x40
    [37316.390360] Modules linked in: nvme_rdma nvme_tcp(X) nvme_fabrics nvme_core netconsole iscsi_tcp libiscsi_tcp dm_queue_length dm_service_time nf_conntrack_netlink br_netfilter bridge stp llc overlay nft_chain_nat ipt_MASQUERADE nf_nat xt_addrtype xt_CT nft_counter xt_state xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 xt_comment xt_multiport nft_compat nf_tables libcrc32c nfnetlink dm_multipath tg3 rpcrdma sunrpc rdma_ucm ib_srpt ib_isert iscsi_target_mod target_core_mod ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm intel_rapl_msr iTCO_wdt iTCO_vendor_support dcdbas intel_rapl_common sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ipmi_ssif kvm irqbypass crct10dif_pclmul crc32_pclmul mlx5_ib ghash_clmulni_intel ib_uverbs rapl intel_cstate intel_uncore ib_core ipmi_si joydev mei_me pcspkr ipmi_devintf mei lpc_ich wmi ipmi_msghandler acpi_power_meter ext4 mbcache jbd2 sd_mod t10_pi sg mgag200 mlx5_core drm_kms_helper syscopyarea
    [37316.390419]  sysfillrect ahci sysimgblt fb_sys_fops libahci drm crc32c_intel libata mlxfw pci_hyperv_intf tls i2c_algo_bit psample dm_mirror dm_region_hash dm_log dm_mod fuse [last unloaded: nvme_core]
    [37317.645908] CR2: 0000000000000050
    
    Fixes: e7d65803e2bb ("nvme-multipath: revalidate paths during rescan")
    Signed-off-by: Caleb Sander <csander@purestorage.com>
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7594956fec8902dfc18150bf1dca0940cd4ad025
Author: Guo Ren <guoren@kernel.org>
Date:   Thu Oct 20 10:16:02 2022 -0400

    riscv: kexec: Fixup irq controller broken in kexec crash path
    
    [ Upstream commit b17d19a5314a37f7197afd1a0200affd21a7227d ]
    
    If a crash happens on cpu3 and all interrupts are binding on cpu0, the
    bad irq routing will cause a crash kernel which can't receive any irq.
    Because crash kernel won't clean up all harts' PLIC enable bits in
    enable registers. This patch is similar to 9141a003a491 ("ARM: 7316/1:
    kexec: EOI active and mask all interrupts in kexec crash path") and
    78fd584cdec0 ("arm64: kdump: implement machine_crash_shutdown()"), and
    PowerPC also has the same mechanism.
    
    Fixes: fba8a8674f68 ("RISC-V: Add kexec support")
    Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
    Signed-off-by: Guo Ren <guoren@kernel.org>
    Reviewed-by: Xianting Tian <xianting.tian@linux.alibaba.com>
    Cc: Nick Kossifidis <mick@ics.forth.gr>
    Cc: Palmer Dabbelt <palmer@rivosinc.com>
    Link: https://lore.kernel.org/r/20221020141603.2856206-2-guoren@kernel.org
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 879fabc5a95401d9bce357e4b1d24ae4a360a81f
Author: Jisheng Zhang <jszhang@kernel.org>
Date:   Sun Oct 30 20:45:17 2022 +0800

    riscv: fix race when vmap stack overflow
    
    [ Upstream commit 7e1864332fbc1b993659eab7974da9fe8bf8c128 ]
    
    Currently, when detecting vmap stack overflow, riscv firstly switches
    to the so called shadow stack, then use this shadow stack to call the
    get_overflow_stack() to get the overflow stack. However, there's
    a race here if two or more harts use the same shadow stack at the same
    time.
    
    To solve this race, we introduce spin_shadow_stack atomic var, which
    will be swap between its own address and 0 in atomic way, when the
    var is set, it means the shadow_stack is being used; when the var
    is cleared, it means the shadow_stack isn't being used.
    
    Fixes: 31da94c25aea ("riscv: add VMAP_STACK overflow detection")
    Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
    Suggested-by: Guo Ren <guoren@kernel.org>
    Reviewed-by: Guo Ren <guoren@kernel.org>
    Link: https://lore.kernel.org/r/20221030124517.2370-1-jszhang@kernel.org
    [Palmer: Add AQ to the swap, and also some comments.]
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 96f479383d92944406d4b3f2bc03c2f640def9f1
Author: Alexandre Ghiti <alexghiti@rivosinc.com>
Date:   Mon Nov 21 14:33:03 2022 +0100

    riscv: Sync efi page table's kernel mappings before switching
    
    [ Upstream commit 3f105a742725a1b78766a55169f1d827732e62b8 ]
    
    The EFI page table is initially created as a copy of the kernel page table.
    With VMAP_STACK enabled, kernel stacks are allocated in the vmalloc area:
    if the stack is allocated in a new PGD (one that was not present at the
    moment of the efi page table creation or not synced in a previous vmalloc
    fault), the kernel will take a trap when switching to the efi page table
    when the vmalloc kernel stack is accessed, resulting in a kernel panic.
    
    Fix that by updating the efi kernel mappings before switching to the efi
    page table.
    
    Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
    Fixes: b91540d52a08 ("RISC-V: Add EFI runtime services")
    Tested-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
    Reviewed-by: Atish Patra <atishp@rivosinc.com>
    Link: https://lore.kernel.org/r/20221121133303.1782246-1-alexghiti@rivosinc.com
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 3c9a4a9b8b22584681e356554b3042d923b929a8
Author: Maxim Korotkov <korotkov.maxim.s@gmail.com>
Date:   Thu Nov 17 15:30:34 2022 +0300

    pinctrl: single: Fix potential division by zero
    
    [ Upstream commit 64c150339e7f6c5cbbe8c17a56ef2b3902612798 ]
    
    There is a possibility of dividing by zero due to the pcs->bits_per_pin
    if pcs->fmask() also has a value of zero and called fls
    from asm-generic/bitops/builtin-fls.h or arch/x86/include/asm/bitops.h.
    The function pcs_probe() has the branch that assigned to fmask 0 before
    pcs_allocate_pin_table() was called
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: 4e7e8017a80e ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules")
    Signed-off-by: Maxim Korotkov <korotkov.maxim.s@gmail.com>
    Reviewed-by: Tony Lindgren <tony@atomide.com>
    Link: https://lore.kernel.org/r/20221117123034.27383-1-korotkov.maxim.s@gmail.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 1a1876d806497f8674c4649a502d6e0409a88f06
Author: Hui Tang <tanghui20@huawei.com>
Date:   Thu May 12 15:46:40 2022 +0800

    ASoC: tlv320adc3xxx: Fix build error for implicit function declaration
    
    [ Upstream commit 19c5bda74dc45fee598a57600b550c9ea7662f10 ]
    
    sound/soc/codecs/tlv320adc3xxx.c: In function ‘adc3xxx_i2c_probe’:
    sound/soc/codecs/tlv320adc3xxx.c:1359:21: error: implicit declaration of function ‘devm_gpiod_get’; did you mean ‘devm_gpio_free’? [-Werror=implicit-function-declaration]
      adc3xxx->rst_pin = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
                         ^~~~~~~~~~~~~~
                         devm_gpio_free
      CC [M]  drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgt215.o
      LD [M]  sound/soc/codecs/snd-soc-ak4671.o
      LD [M]  sound/soc/codecs/snd-soc-arizona.o
      LD [M]  sound/soc/codecs/snd-soc-cros-ec-codec.o
      LD [M]  sound/soc/codecs/snd-soc-ak4641.o
      LD [M]  sound/soc/codecs/snd-soc-alc5632.o
    sound/soc/codecs/tlv320adc3xxx.c:1359:50: error: ‘GPIOD_OUT_LOW’ undeclared (first use in this function); did you mean ‘GPIOF_INIT_LOW’?
      adc3xxx->rst_pin = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
                                                      ^~~~~~~~~~~~~
                                                      GPIOF_INIT_LOW
    sound/soc/codecs/tlv320adc3xxx.c:1359:50: note: each undeclared identifier is reported only once for each function it appears in
      LD [M]  sound/soc/codecs/snd-soc-cs35l32.o
    sound/soc/codecs/tlv320adc3xxx.c:1408:2: error: implicit declaration of function ‘gpiod_set_value_cansleep’; did you mean ‘gpio_set_value_cansleep’? [-Werror=implicit-function-declaration]
      gpiod_set_value_cansleep(adc3xxx->rst_pin, 1);
      ^~~~~~~~~~~~~~~~~~~~~~~~
      gpio_set_value_cansleep
      LD [M]  sound/soc/codecs/snd-soc-cs35l41-lib.o
      LD [M]  sound/soc/codecs/snd-soc-cs35l36.o
      LD [M]  sound/soc/codecs/snd-soc-cs35l34.o
      LD [M]  sound/soc/codecs/snd-soc-cs35l41.o
      CC [M]  drivers/gpu/drm/nouveau/nvkm/engine/disp/sormcp89.o
    cc1: all warnings being treated as errors
    
    Fixes: e9a3b57efd28 ("ASoC: codec: tlv320adc3xxx: New codec driver")
    Signed-off-by: Hui Tang <tanghui20@huawei.com>
    Link: https://lore.kernel.org/r/20220512074640.75550-3-tanghui20@huawei.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 325d94d16e3131b54bdf07356e4cd855e0d853fc
Author: Mark Brown <broonie@kernel.org>
Date:   Wed May 11 14:41:36 2022 +0100

    ASoC: ops: Fix bounds check for _sx controls
    
    [ Upstream commit 698813ba8c580efb356ace8dbf55f61dac6063a8 ]
    
    For _sx controls the semantics of the max field is not the usual one, max
    is the number of steps rather than the maximum value. This means that our
    check in snd_soc_put_volsw_sx() needs to just check against the maximum
    value.
    
    Fixes: 4f1e50d6a9cf9c1b ("ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx()")
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Link: https://lore.kernel.org/r/20220511134137.169575-1-broonie@kernel.org
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c52d0c8c4f38f7580cff61c4dfe1034c580cedfd
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Wed Nov 23 17:14:34 2022 -0500

    tracing: Free buffers when a used dynamic event is removed
    
    commit 4313e5a613049dfc1819a6dfb5f94cf2caff9452 upstream.
    
    After 65536 dynamic events have been added and removed, the "type" field
    of the event then uses the first type number that is available (not
    currently used by other events). A type number is the identifier of the
    binary blobs in the tracing ring buffer (known as events) to map them to
    logic that can parse the binary blob.
    
    The issue is that if a dynamic event (like a kprobe event) is traced and
    is in the ring buffer, and then that event is removed (because it is
    dynamic, which means it can be created and destroyed), if another dynamic
    event is created that has the same number that new event's logic on
    parsing the binary blob will be used.
    
    To show how this can be an issue, the following can crash the kernel:
    
     # cd /sys/kernel/tracing
     # for i in `seq 65536`; do
         echo 'p:kprobes/foo do_sys_openat2 $arg1:u32' > kprobe_events
     # done
    
    For every iteration of the above, the writing to the kprobe_events will
    remove the old event and create a new one (with the same format) and
    increase the type number to the next available on until the type number
    reaches over 65535 which is the max number for the 16 bit type. After it
    reaches that number, the logic to allocate a new number simply looks for
    the next available number. When an dynamic event is removed, that number
    is then available to be reused by the next dynamic event created. That is,
    once the above reaches the max number, the number assigned to the event in
    that loop will remain the same.
    
    Now that means deleting one dynamic event and created another will reuse
    the previous events type number. This is where bad things can happen.
    After the above loop finishes, the kprobes/foo event which reads the
    do_sys_openat2 function call's first parameter as an integer.
    
     # echo 1 > kprobes/foo/enable
     # cat /etc/passwd > /dev/null
     # cat trace
                 cat-2211    [005] ....  2007.849603: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                 cat-2211    [005] ....  2007.849620: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                 cat-2211    [005] ....  2007.849838: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
                 cat-2211    [005] ....  2007.849880: foo: (do_sys_openat2+0x0/0x130) arg1=4294967196
     # echo 0 > kprobes/foo/enable
    
    Now if we delete the kprobe and create a new one that reads a string:
    
     # echo 'p:kprobes/foo do_sys_openat2 +0($arg2):string' > kprobe_events
    
    And now we can the trace:
    
     # cat trace
            sendmail-1942    [002] .....   530.136320: foo: (do_sys_openat2+0x0/0x240) arg1=             cat-2046    [004] .....   530.930817: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                 cat-2046    [004] .....   530.930961: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                 cat-2046    [004] .....   530.934278: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                 cat-2046    [004] .....   530.934563: foo: (do_sys_openat2+0x0/0x240) arg1="������������������������������������������������������������������������������������������������"
                bash-1515    [007] .....   534.299093: foo: (do_sys_openat2+0x0/0x240) arg1="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk���������@��4Z����;Y�����U
    
    And dmesg has:
    
    ==================================================================
    BUG: KASAN: use-after-free in string+0xd4/0x1c0
    Read of size 1 at addr ffff88805fdbbfa0 by task cat/2049
    
     CPU: 0 PID: 2049 Comm: cat Not tainted 6.1.0-rc6-test+ #641
     Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
     Call Trace:
      <TASK>
      dump_stack_lvl+0x5b/0x77
      print_report+0x17f/0x47b
      kasan_report+0xad/0x130
      string+0xd4/0x1c0
      vsnprintf+0x500/0x840
      seq_buf_vprintf+0x62/0xc0
      trace_seq_printf+0x10e/0x1e0
      print_type_string+0x90/0xa0
      print_kprobe_event+0x16b/0x290
      print_trace_line+0x451/0x8e0
      s_show+0x72/0x1f0
      seq_read_iter+0x58e/0x750
      seq_read+0x115/0x160
      vfs_read+0x11d/0x460
      ksys_read+0xa9/0x130
      do_syscall_64+0x3a/0x90
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
     RIP: 0033:0x7fc2e972ade2
     Code: c0 e9 b2 fe ff ff 50 48 8d 3d b2 3f 0a 00 e8 05 f0 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24
     RSP: 002b:00007ffc64e687c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
     RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007fc2e972ade2
     RDX: 0000000000020000 RSI: 00007fc2e980d000 RDI: 0000000000000003
     RBP: 00007fc2e980d000 R08: 00007fc2e980c010 R09: 0000000000000000
     R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020f00
     R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
      </TASK>
    
     The buggy address belongs to the physical page:
     page:ffffea00017f6ec0 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5fdbb
     flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
     raw: 000fffffc0000000 0000000000000000 ffffea00017f6ec8 0000000000000000
     raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
     page dumped because: kasan: bad access detected
    
     Memory state around the buggy address:
      ffff88805fdbbe80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      ffff88805fdbbf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
     >ffff88805fdbbf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                    ^
      ffff88805fdbc000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      ffff88805fdbc080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
     ==================================================================
    
    This was found when Zheng Yejian sent a patch to convert the event type
    number assignment to use IDA, which gives the next available number, and
    this bug showed up in the fuzz testing by Yujie Liu and the kernel test
    robot. But after further analysis, I found that this behavior is the same
    as when the event type numbers go past the 16bit max (and the above shows
    that).
    
    As modules have a similar issue, but is dealt with by setting a
    "WAS_ENABLED" flag when a module event is enabled, and when the module is
    freed, if any of its events were enabled, the ring buffer that holds that
    event is also cleared, to prevent reading stale events. The same can be
    done for dynamic events.
    
    If any dynamic event that is being removed was enabled, then make sure the
    buffers they were enabled in are now cleared.
    
    Link: https://lkml.kernel.org/r/20221123171434.545706e3@gandalf.local.home
    Link: https://lore.kernel.org/all/20221110020319.1259291-1-zhengyejian1@huawei.com/
    
    Cc: stable@vger.kernel.org
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Depends-on: e18eb8783ec49 ("tracing: Add tracing_reset_all_online_cpus_unlocked() function")
    Depends-on: 5448d44c38557 ("tracing: Add unified dynamic event framework")
    Depends-on: 6212dd29683ee ("tracing/kprobes: Use dyn_event framework for kprobe events")
    Depends-on: 065e63f951432 ("tracing: Only have rmmod clear buffers that its events were active in")
    Depends-on: 575380da8b469 ("tracing: Only clear trace buffer on module unload if event was traced")
    Fixes: 77b44d1b7c283 ("tracing/kprobes: Rename Kprobe-tracer to kprobe-event")
    Reported-by: Zheng Yejian <zhengyejian1@huawei.com>
    Reported-by: Yujie Liu <yujie.liu@intel.com>
    Reported-by: kernel test robot <yujie.liu@intel.com>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 388dedd10663d21a98bcddffa7af61dfb9328c46
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Wed Nov 23 16:43:23 2022 -0500

    tracing: Fix race where histograms can be called before the event
    
    commit ef38c79a522b660f7f71d45dad2d6244bc741841 upstream.
    
    commit 94eedf3dded5 ("tracing: Fix race where eprobes can be called before
    the event") fixed an issue where if an event is soft disabled, and the
    trigger is being added, there's a small window where the event sees that
    there's a trigger but does not see that it requires reading the event yet,
    and then calls the trigger with the record == NULL.
    
    This could be solved with adding memory barriers in the hot path, or to
    make sure that all the triggers requiring a record check for NULL. The
    latter was chosen.
    
    Commit 94eedf3dded5 set the eprobe trigger handle to check for NULL, but
    the same needs to be done with histograms.
    
    Link: https://lore.kernel.org/linux-trace-kernel/20221118211809.701d40c0f8a757b0df3c025a@kernel.org/
    Link: https://lore.kernel.org/linux-trace-kernel/20221123164323.03450c3a@gandalf.local.home
    
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: stable@vger.kernel.org
    Fixes: 7491e2c442781 ("tracing: Add a probe that attaches to trace events")
    Reported-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07e1926dcf294e6dd85d14aa80b340e3bd10a1cb
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Thu Nov 17 14:46:17 2022 +0100

    tracing/osnoise: Fix duration type
    
    commit 022632f6c43a86f2135642dccd5686de318e861d upstream.
    
    The duration type is a 64 long value, not an int. This was
    causing some long noise to report wrong values.
    
    Change the duration to a 64 bits value.
    
    Link: https://lkml.kernel.org/r/a93d8a8378c7973e9c609de05826533c9e977939.1668692096.git.bristot@kernel.org
    
    Cc: stable@vger.kernel.org
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Fixes: bce29ac9ce0b ("trace: Add osnoise tracer")
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 943c94dbf6dd0fb96bf49e26ae799f8e883c8904
Author: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Date:   Mon Nov 21 15:56:55 2022 +0100

    drm/i915: Never return 0 if not all requests retired
    
    commit 12b8b046e4c9de40fa59b6f067d6826f4e688f68 upstream.
    
    Users of intel_gt_retire_requests_timeout() expect 0 return value on
    success.  However, we have no protection from passing back 0 potentially
    returned by a call to dma_fence_wait_timeout() when it succedes right
    after its timeout has expired.
    
    Replace 0 with -ETIME before potentially using the timeout value as return
    code, so -ETIME is returned if there are still some requests not retired
    after timeout, 0 otherwise.
    
    v3: Use conditional expression, more compact but also better reflecting
        intention standing behind the change.
    
    v2: Move the added lines down so flush_submission() is not affected.
    
    Fixes: f33a8a51602c ("drm/i915: Merge wait_for_timelines with retire_request")
    Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
    Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
    Cc: stable@vger.kernel.org # v5.5+
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221121145655.75141-3-janusz.krzysztofik@linux.intel.com
    (cherry picked from commit f301a29f143760ce8d3d6b6a8436d45d3448cde6)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c616b72043bd91b4dfd2c2c716b3df61b33731e8
Author: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Date:   Mon Nov 21 15:56:54 2022 +0100

    drm/i915: Fix negative value passed as remaining time
    
    commit a8899b8728013c7b2456f0bfa20e5fea85ee0fd1 upstream.
    
    Commit b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work
    with GuC") extended the API of intel_gt_retire_requests_timeout() with an
    extra argument 'remaining_timeout', intended for passing back unconsumed
    portion of requested timeout when 0 (success) is returned.  However, when
    request retirement happens to succeed despite an error returned by a call
    to dma_fence_wait_timeout(), that error code (a negative value) is passed
    back instead of remaining time.  If we then pass that negative value
    forward as requested timeout to intel_uc_wait_for_idle(), an explicit BUG
    will be triggered.
    
    If request retirement succeeds but an error code is passed back via
    remaininig_timeout, we may have no clue on how much of the initial timeout
    might have been left for spending it on waiting for GuC to become idle.
    OTOH, since all pending requests have been successfully retired, that
    error code has been already ignored by intel_gt_retire_requests_timeout(),
    then we shouldn't fail.
    
    Assume no more time has been left on error and pass 0 timeout value to
    intel_uc_wait_for_idle() to give it a chance to return success if GuC is
    already idle.
    
    v3: Don't fail on any error passed back via remaining_timeout.
    
    v2: Fix the issue on the caller side, not the provider.
    
    Fixes: b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
    Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
    Cc: stable@vger.kernel.org # v5.15+
    Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221121145655.75141-2-janusz.krzysztofik@linux.intel.com
    (cherry picked from commit f235dbd5b768e238d365fd05d92de5a32abc1c1f)
    Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit da8ffd890717420714d2b31657bb94a6940e8eb9
Author: Leo Liu <leo.liu@amd.com>
Date:   Tue Nov 29 18:53:18 2022 -0500

    drm/amdgpu: enable Vangogh VCN indirect sram mode
    
    commit 9a8cc8cabc1e351614fd7f9e774757a5143b6fe8 upstream.
    
    So that uses PSP to initialize HW.
    
    Fixes: 0c2c02b66c672e ("drm/amdgpu/vcn: add firmware support for dimgrey_cavefish")
    Signed-off-by: Leo Liu <leo.liu@amd.com>
    Reviewed-by: James Zhu <James.Zhu@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 327d1f01a21eaad6184d3d4c192bb7954a6c810e
Author: Lee Jones <lee@kernel.org>
Date:   Fri Nov 25 12:07:49 2022 +0000

    drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
    
    commit 6f6cb1714365a07dbc66851879538df9f6969288 upstream.
    
    Patch series "Fix a bunch of allmodconfig errors", v2.
    
    Since b339ec9c229aa ("kbuild: Only default to -Werror if COMPILE_TEST")
    WERROR now defaults to COMPILE_TEST meaning that it's enabled for
    allmodconfig builds.  This leads to some interesting build failures when
    using Clang, each resolved in this set.
    
    With this set applied, I am able to obtain a successful allmodconfig Arm
    build.
    
    
    This patch (of 2):
    
    calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 ||
    ARM64) architectures built with Clang (all released versions), whereby the
    stack frame gets blown up to well over 5k.  This would cause an immediate
    kernel panic on most architectures.  We'll revert this when the following
    bug report has been resolved:
    https://github.com/llvm/llvm-project/issues/41896.
    
    Link: https://lkml.kernel.org/r/20221125120750.3537134-1-lee@kernel.org
    Link: https://lkml.kernel.org/r/20221125120750.3537134-2-lee@kernel.org
    Signed-off-by: Lee Jones <lee@kernel.org>
    Suggested-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: David Airlie <airlied@gmail.com>
    Cc: Harry Wentland <harry.wentland@amd.com>
    Cc: Lee Jones <lee@kernel.org>
    Cc: Leo Li <sunpeng.li@amd.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
    Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Tom Rix <trix@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5e581e15dc40de6b949e51b64dc3780c3857b3d4
Author: Lee Jones <lee@kernel.org>
Date:   Fri Nov 25 12:07:50 2022 +0000

    Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
    
    commit 152fe65f300e1819d59b80477d3e0999b4d5d7d2 upstream.
    
    When enabled, KASAN enlarges function's stack-frames.  Pushing quite a few
    over the current threshold.  This can mainly be seen on 32-bit
    architectures where the present limit (when !GCC) is a lowly 1024-Bytes.
    
    Link: https://lkml.kernel.org/r/20221125120750.3537134-3-lee@kernel.org
    Signed-off-by: Lee Jones <lee@kernel.org>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: David Airlie <airlied@gmail.com>
    Cc: Harry Wentland <harry.wentland@amd.com>
    Cc: Leo Li <sunpeng.li@amd.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
    Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Tom Rix <trix@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit eb7c0fdb07e3f96d89a12830c7b5068c08f31fe8
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Mon Nov 28 15:32:56 2022 +0200

    mmc: sdhci: Fix voltage switch delay
    
    commit c981cdfb9925f64a364f13c2b4f98f877308a408 upstream.
    
    Commit 20b92a30b561 ("mmc: sdhci: update signal voltage switch code")
    removed voltage switch delays from sdhci because mmc core had been
    enhanced to support them. However that assumed that sdhci_set_ios()
    did a single clock change, which it did not, and so the delays in mmc
    core, which should have come after the first clock change, were not
    effective.
    
    Fix by avoiding re-configuring UHS and preset settings when the clock
    is turning on and the settings have not changed. That then also avoids
    the associated clock changes, so that then sdhci_set_ios() does a single
    clock change when voltage switching, and the mmc core delays become
    effective.
    
    To do that has meant keeping track of driver strength (host->drv_type),
    and cases of reinitialization (host->reinit_uhs).
    
    Note also, the 'turning_on_clk' restriction should not be necessary
    but is done to minimize the impact of the change on stable kernels.
    
    Fixes: 20b92a30b561 ("mmc: sdhci: update signal voltage switch code")
    Cc: stable@vger.kernel.org
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Link: https://lore.kernel.org/r/20221128133259.38305-2-adrian.hunter@intel.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab5cdcccf9775a066bbe48b14f7c1d2c8eaf79b1
Author: Wenchao Chen <wenchao.chen@unisoc.com>
Date:   Wed Nov 30 20:13:28 2022 +0800

    mmc: sdhci-sprd: Fix no reset data and command after voltage switch
    
    commit dd30dcfa7a74a06f8dcdab260d8d5adf32f17333 upstream.
    
    After switching the voltage, no reset data and command will cause
    CMD2 timeout.
    
    Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
    Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221130121328.25553-1-wenchao.chen@unisoc.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e915679e4249108323a915388eeb337b348c7522
Author: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
Date:   Mon Nov 21 11:57:21 2022 +0100

    mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check
    
    commit a3cab1d2132474969871b5d7f915c5c0167b48b0 upstream.
    
    With the current logic the "failed to exit halt state" error would be
    shown even if any other bit than CQHCI_HALT was set in the CQHCI_CTL
    register, since the right hand side is always true. Fix this by using
    the correct operator (bit-wise instead of logical AND) to only check for
    the halt bit flag, which was obviously intended here.
    
    Fixes: 85236d2be844 ("mmc: sdhci-esdhc-imx: clear the HALT bit when enable CQE")
    Signed-off-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
    Acked-by: Haibo Chen <haibo.chen@nxp.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221121105721.1903878-1-sebastian.falbesoner@gmail.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ef9d8e3b1edcea076089b6da508d20cae8126dbc
Author: Christian Löhle <CLoehle@hyperstone.com>
Date:   Thu Nov 17 14:42:09 2022 +0000

    mmc: core: Fix ambiguous TRIM and DISCARD arg
    
    commit 489d144563f23911262a652234b80c70c89c978b upstream.
    
    Clean up the MMC_TRIM_ARGS define that became ambiguous with DISCARD
    introduction.  While at it, let's fix one usage where MMC_TRIM_ARGS falsely
    included DISCARD too.
    
    Fixes: b3bf915308ca ("mmc: core: new discard feature support at eMMC v4.5")
    Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/11376b5714964345908f3990f17e0701@hyperstone.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e82ae7fa2c9049b2a8be8e988b2bde7dbdb0abb9
Author: Gaosheng Cui <cuigaosheng1@huawei.com>
Date:   Fri Nov 25 17:01:41 2022 +0800

    mmc: mtk-sd: Fix missing clk_disable_unprepare in msdc_of_clock_parse()
    
    commit c61bfb1cb63ddab52b31cf5f1924688917e61fad upstream.
    
    The clk_disable_unprepare() should be called in the error handling
    of devm_clk_bulk_get_optional, fix it by replacing devm_clk_get_optional
    and clk_prepare_enable by devm_clk_get_optional_enabled.
    
    Fixes: f5eccd94b63f ("mmc: mediatek: Add subsys clock control for MT8192 msdc")
    Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221125090141.3626747-1-cuigaosheng1@huawei.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 237acfc6088a14df0ba612aadeaec4d89dbd63ff
Author: Ye Bin <yebin10@huawei.com>
Date:   Wed Nov 23 17:55:06 2022 +0800

    mmc: mmc_test: Fix removal of debugfs file
    
    commit f4307b4df1c28842bb1950ff0e1b97e17031b17f upstream.
    
    In __mmc_test_register_dbgfs_file(), we need to assign 'file', as it's
    being used when removing the debugfs files when the mmc_test module is
    removed.
    
    Fixes: a04c50aaa916 ("mmc: core: no need to check return value of debugfs_create functions")
    Signed-off-by: Ye Bin <yebin10@huawei.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Cc: stable@vger.kernel.org
    [Ulf: Re-wrote the commit msg]
    Link: https://lore.kernel.org/r/20221123095506.1965691-1-yebin@huaweicloud.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 74830718e44a8d0222117dbd9343b87d9034e291
Author: Goh, Wei Sheng <wei.sheng.goh@intel.com>
Date:   Wed Nov 23 18:51:10 2022 +0800

    net: stmmac: Set MAC's flow control register to reflect current settings
    
    commit cc3d2b5fc0d6f8ad8a52da5ea679e5c2ec2adbd4 upstream.
    
    Currently, pause frame register GMAC_RX_FLOW_CTRL_RFE is not updated
    correctly when 'ethtool -A <IFACE> autoneg off rx off tx off' command
    is issued. This fix ensures the flow control change is reflected directly
    in the GMAC_RX_FLOW_CTRL_RFE register.
    
    Fixes: 46f69ded988d ("net: stmmac: Use resolved link config in mac_link_up()")
    Cc: <stable@vger.kernel.org> # 5.10.x
    Signed-off-by: Goh, Wei Sheng <wei.sheng.goh@intel.com>
    Signed-off-by: Noor Azura Ahmad Tarmizi <noor.azura.ahmad.tarmizi@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6d01bb8b5ff0b816df7357f193e36fe8a496bc4c
Author: Gavin Shan <gshan@redhat.com>
Date:   Thu Nov 24 17:55:23 2022 +0800

    mm: migrate: fix THP's mapcount on isolation
    
    commit 829ae0f81ce093d674ff2256f66a714753e9ce32 upstream.
    
    The issue is reported when removing memory through virtio_mem device.  The
    transparent huge page, experienced copy-on-write fault, is wrongly
    regarded as pinned.  The transparent huge page is escaped from being
    isolated in isolate_migratepages_block().  The transparent huge page can't
    be migrated and the corresponding memory block can't be put into offline
    state.
    
    Fix it by replacing page_mapcount() with total_mapcount().  With this, the
    transparent huge page can be isolated and migrated, and the memory block
    can be put into offline state.  Besides, The page's refcount is increased
    a bit earlier to avoid the page is released when the check is executed.
    
    Link: https://lkml.kernel.org/r/20221124095523.31061-1-gshan@redhat.com
    Fixes: 1da2f328fa64 ("mm,thp,compaction,cma: allow THP migration for CMA allocations")
    Signed-off-by: Gavin Shan <gshan@redhat.com>
    Reported-by: Zhenyu Zhang <zhenyzha@redhat.com>
    Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
    Suggested-by: David Hildenbrand <david@redhat.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Cc: Alistair Popple <apopple@nvidia.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: William Kucharski <william.kucharski@oracle.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Cc: <stable@vger.kernel.org>    [5.7+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0e3f94b260aeb699526965a3d5a5753234abd6bd
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Wed Nov 30 16:10:52 2022 -0800

    v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails
    
    commit 6647e76ab623b2b3fb2efe03a86e9c9046c52c33 upstream.
    
    The V4L2_MEMORY_USERPTR interface is long deprecated and shouldn't be
    used (and is discouraged for any modern v4l drivers).  And Seth Jenkins
    points out that the fallback to VM_PFNMAP/VM_IO is fundamentally racy
    and dangerous.
    
    Note that it's not even a case that should trigger, since any normal
    user pointer logic ends up just using the pin_user_pages_fast() call
    that does the proper page reference counting.  That's not the problem
    case, only if you try to use special device mappings do you have any
    issues.
    
    Normally I'd just remove this during the merge window, but since Seth
    pointed out the problem cases, we really want to know as soon as
    possible if there are actually any users of this odd special case of a
    legacy interface.  Neither Hans nor Mauro seem to think that such
    mis-uses of the old legacy interface should exist.  As Mauro says:
    
     "See, V4L2 has actually 4 streaming APIs:
            - Kernel-allocated mmap (usually referred simply as just mmap);
            - USERPTR mmap;
            - read();
            - dmabuf;
    
      The USERPTR is one of the oldest way to use it, coming from V4L
      version 1 times, and by far the least used one"
    
    And Hans chimed in on the USERPTR interface:
    
     "To be honest, I wouldn't mind if it goes away completely, but that's a
      bit of a pipe dream right now"
    
    but while removing this legacy interface entirely may be a pipe dream we
    can at least try to remove the unlikely (and actively broken) case of
    using special device mappings for USERPTR accesses.
    
    This replaces it with a WARN_ONCE() that we can remove once we've
    hopefully confirmed that no actual users exist.
    
    NOTE! Longer term, this means that a 'struct frame_vector' only ever
    contains proper page pointers, and all the games we have with converting
    them to pages can go away (grep for 'frame_vector_to_pages()' and the
    uses of 'vec->is_pfns').  But this is just the first step, to verify
    that this code really is all dead, and do so as quickly as possible.
    
    Reported-by: Seth Jenkins <sethjenkins@google.com>
    Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
    Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Jan Kara <jack@suse.cz>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e3f02a0f9d559ab7fb60715f74320730f1e3b6d6
Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date:   Fri Nov 25 00:29:26 2022 +0200

    pinctrl: intel: Save and restore pins in "direct IRQ" mode
    
    commit 6989ea4881c8944fbf04378418bb1af63d875ef8 upstream.
    
    The firmware on some systems may configure GPIO pins to be
    an interrupt source in so called "direct IRQ" mode. In such
    cases the GPIO controller driver has no idea if those pins
    are being used or not. At the same time, there is a known bug
    in the firmwares that don't restore the pin settings correctly
    after suspend, i.e. by an unknown reason the Rx value becomes
    inverted.
    
    Hence, let's save and restore the pins that are configured
    as GPIOs in the input mode with GPIROUTIOXAPIC bit set.
    
    Cc: stable@vger.kernel.org
    Reported-and-tested-by: Dale Smith <dalepsmith@gmail.com>
    Reported-and-tested-by: John Harris <jmharris@gmail.com>
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214749
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Link: https://lore.kernel.org/r/20221124222926.72326-1-andriy.shevchenko@linux.intel.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8cec645491db208177154b328f15cf4da944533a
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Date:   Wed Nov 30 07:25:51 2022 -0800

    x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3
    
    commit 66065157420c5b9b3f078f43d313c153e1ff7f83 upstream.
    
    The "force" argument to write_spec_ctrl_current() is currently ambiguous
    as it does not guarantee the MSR write. This is due to the optimization
    that writes to the MSR happen only when the new value differs from the
    cached value.
    
    This is fine in most cases, but breaks for S3 resume when the cached MSR
    value gets out of sync with the hardware MSR value due to S3 resetting
    it.
    
    When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write
    is skipped. Which results in SPEC_CTRL mitigations not getting restored.
    
    Move the MSR write from write_spec_ctrl_current() to a new function that
    unconditionally writes to the MSR. Update the callers accordingly and
    rename functions.
    
      [ bp: Rework a bit. ]
    
    Fixes: caa0ff24d5d0 ("x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value")
    Suggested-by: Borislav Petkov <bp@alien8.de>
    Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: <stable@kernel.org>
    Link: https://lore.kernel.org/r/806d39b0bfec2fe8f50dc5446dff20f5bb24a959.1669821572.git.pawan.kumar.gupta@linux.intel.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 381b84f60e549ea98cec4666c6c728b1b3318756
Author: ZhangPeng <zhangpeng362@huawei.com>
Date:   Sat Nov 19 21:05:42 2022 +0900

    nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()
    
    commit f0a0ccda18d6fd826d7c7e7ad48a6ed61c20f8b4 upstream.
    
    Syzbot reported a null-ptr-deref bug:
    
     NILFS (loop0): segctord starting. Construction interval = 5 seconds, CP
     frequency < 30 seconds
     general protection fault, probably for non-canonical address
     0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
     KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
     CPU: 1 PID: 3603 Comm: segctord Not tainted
     6.1.0-rc2-syzkaller-00105-gb229b6ca5abb #0
     Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google
     10/11/2022
     RIP: 0010:nilfs_palloc_commit_free_entry+0xe5/0x6b0
     fs/nilfs2/alloc.c:608
     Code: 00 00 00 00 fc ff df 80 3c 02 00 0f 85 cd 05 00 00 48 b8 00 00 00
     00 00 fc ff df 4c 8b 73 08 49 8d 7e 10 48 89 fa 48 c1 ea 03 <80> 3c 02
     00 0f 85 26 05 00 00 49 8b 46 10 be a6 00 00 00 48 c7 c7
     RSP: 0018:ffffc90003dff830 EFLAGS: 00010212
     RAX: dffffc0000000000 RBX: ffff88802594e218 RCX: 000000000000000d
     RDX: 0000000000000002 RSI: 0000000000002000 RDI: 0000000000000010
     RBP: ffff888071880222 R08: 0000000000000005 R09: 000000000000003f
     R10: 000000000000000d R11: 0000000000000000 R12: ffff888071880158
     R13: ffff88802594e220 R14: 0000000000000000 R15: 0000000000000004
     FS:  0000000000000000(0000) GS:ffff8880b9b00000(0000)
     knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 00007fb1c08316a8 CR3: 0000000018560000 CR4: 0000000000350ee0
     Call Trace:
      <TASK>
      nilfs_dat_commit_free fs/nilfs2/dat.c:114 [inline]
      nilfs_dat_commit_end+0x464/0x5f0 fs/nilfs2/dat.c:193
      nilfs_dat_commit_update+0x26/0x40 fs/nilfs2/dat.c:236
      nilfs_btree_commit_update_v+0x87/0x4a0 fs/nilfs2/btree.c:1940
      nilfs_btree_commit_propagate_v fs/nilfs2/btree.c:2016 [inline]
      nilfs_btree_propagate_v fs/nilfs2/btree.c:2046 [inline]
      nilfs_btree_propagate+0xa00/0xd60 fs/nilfs2/btree.c:2088
      nilfs_bmap_propagate+0x73/0x170 fs/nilfs2/bmap.c:337
      nilfs_collect_file_data+0x45/0xd0 fs/nilfs2/segment.c:568
      nilfs_segctor_apply_buffers+0x14a/0x470 fs/nilfs2/segment.c:1018
      nilfs_segctor_scan_file+0x3f4/0x6f0 fs/nilfs2/segment.c:1067
      nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1197 [inline]
      nilfs_segctor_collect fs/nilfs2/segment.c:1503 [inline]
      nilfs_segctor_do_construct+0x12fc/0x6af0 fs/nilfs2/segment.c:2045
      nilfs_segctor_construct+0x8e3/0xb30 fs/nilfs2/segment.c:2379
      nilfs_segctor_thread_construct fs/nilfs2/segment.c:2487 [inline]
      nilfs_segctor_thread+0x3c3/0xf30 fs/nilfs2/segment.c:2570
      kthread+0x2e4/0x3a0 kernel/kthread.c:376
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
      </TASK>
     ...
    
    If DAT metadata file is corrupted on disk, there is a case where
    req->pr_desc_bh is NULL and blocknr is 0 at nilfs_dat_commit_end() during
    a b-tree operation that cascadingly updates ancestor nodes of the b-tree,
    because nilfs_dat_commit_alloc() for a lower level block can initialize
    the blocknr on the same DAT entry between nilfs_dat_prepare_end() and
    nilfs_dat_commit_end().
    
    If this happens, nilfs_dat_commit_end() calls nilfs_dat_commit_free()
    without valid buffer heads in req->pr_desc_bh and req->pr_bitmap_bh, and
    causes the NULL pointer dereference above in
    nilfs_palloc_commit_free_entry() function, which leads to a crash.
    
    Fix this by adding a NULL check on req->pr_desc_bh and req->pr_bitmap_bh
    before nilfs_palloc_commit_free_entry() in nilfs_dat_commit_free().
    
    This also calls nilfs_error() in that case to notify that there is a fatal
    flaw in the filesystem metadata and prevent further operations.
    
    Link: https://lkml.kernel.org/r/00000000000097c20205ebaea3d6@google.com
    Link: https://lkml.kernel.org/r/20221114040441.1649940-1-zhangpeng362@huawei.com
    Link: https://lkml.kernel.org/r/20221119120542.17204-1-konishi.ryusuke@gmail.com
    Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Reported-by: syzbot+ebe05ee8e98f755f61d0@syzkaller.appspotmail.com
    Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 93a87205469b68b07fc8f2c9d724794372847769
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Sat Nov 19 10:36:59 2022 +0800

    tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"
    
    commit a435874bf626f55d7147026b059008c8de89fbb8 upstream.
    
    The latest version of grep claims the egrep is now obsolete so the build
    now contains warnings that look like:
    
            egrep: warning: egrep is obsolescent; using grep -E
    
    fix this up by moving the related file to use "grep -E" instead.
    
      sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/vm`
    
    Here are the steps to install the latest grep:
    
      wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
      tar xf grep-3.8.tar.gz
      cd grep-3.8 && ./configure && make
      sudo make install
      export PATH=/usr/local/bin:$PATH
    
    Link: https://lkml.kernel.org/r/1668825419-30584-1-git-send-email-yangtiezhu@loongson.cn
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit de7b48decb49376c3b119f97e07517a1327e1f34
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Mon Nov 21 10:44:03 2022 -0500

    error-injection: Add prompt for function error injection
    
    commit a4412fdd49dc011bcc2c0d81ac4cab7457092650 upstream.
    
    The config to be able to inject error codes into any function annotated
    with ALLOW_ERROR_INJECTION() is enabled when FUNCTION_ERROR_INJECTION is
    enabled.  But unfortunately, this is always enabled on x86 when KPROBES
    is enabled, and there's no way to turn it off.
    
    As kprobes is useful for observability of the kernel, it is useful to
    have it enabled in production environments.  But error injection should
    be avoided.  Add a prompt to the config to allow it to be disabled even
    when kprobes is enabled, and get rid of the "def_bool y".
    
    This is a kernel debug feature (it's in Kconfig.debug), and should have
    never been something enabled by default.
    
    Cc: stable@vger.kernel.org
    Fixes: 540adea3809f6 ("error-injection: Separate error-injection from kprobe")
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 797b1d9fc0e1f4351e4ad49b078c1a3cdc0d4a08
Author: Ziyang Xuan <william.xuanziyang@huawei.com>
Date:   Thu Nov 10 14:14:37 2022 +0800

    can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down
    
    commit 8fa452cfafed521aaf5a18c71003fe24b1ee6141 upstream.
    
    In can327_feed_frame_to_netdev(), it did not free the skb when netdev
    is down, and all callers of can327_feed_frame_to_netdev() did not free
    allocated skb too. That would trigger skb leak.
    
    Fix it by adding kfree_skb() in can327_feed_frame_to_netdev() when netdev
    is down. Not tested, just compiled.
    
    Fixes: 43da2f07622f ("can: can327: CAN/ldisc driver for ELM327 based OBD-II adapters")
    Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
    Link: https://lore.kernel.org/all/20221110061437.411525-1-william.xuanziyang@huawei.com
    Reviewed-by: Max Staudt <max@enpas.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7c80ce85429fbd98a9d0a605cac21684f97505d7
Author: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Date:   Wed Nov 30 22:06:04 2022 +0900

    ALSA: dice: fix regression for Lexicon I-ONIX FW810S
    
    commit 9b84f0f74d0d716e3fd18dc428ac111266ef5844 upstream.
    
    For Lexicon I-ONIX FW810S, the call of ioctl(2) with
    SNDRV_PCM_IOCTL_HW_PARAMS can returns -ETIMEDOUT. This is a regression due
    to the commit 41319eb56e19 ("ALSA: dice: wait just for
    NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation"). The device
    does not emit NOTIFY_CLOCK_ACCEPTED notification when accepting
    GLOBAL_CLOCK_SELECT operation with the same parameters as current ones.
    
    This commit fixes the regression. When receiving no notification, return
    -ETIMEDOUT as long as operating for any change.
    
    Fixes: 41319eb56e19 ("ALSA: dice: wait just for NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
    Link: https://lore.kernel.org/r/20221130130604.29774-1-o-takashi@sakamocchi.jp
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3d36a150f2d56e33f5ed39d610e28bf641987c9d
Author: Björn Töpel <bjorn@rivosinc.com>
Date:   Tue Nov 15 10:06:40 2022 +0100

    riscv: mm: Proper page permissions after initmem free
    
    commit 6fdd5d2f8c2f54b7fad4ff4df2a19542aeaf6102 upstream.
    
    64-bit RISC-V kernels have the kernel image mapped separately to alias
    the linear map. The linear map and the kernel image map are documented
    as "direct mapping" and "kernel" respectively in [1].
    
    At image load time, the linear map corresponding to the kernel image
    is set to PAGE_READ permission, and the kernel image map is set to
    PAGE_READ|PAGE_EXEC.
    
    When the initmem is freed, the pages in the linear map should be
    restored to PAGE_READ|PAGE_WRITE, whereas the corresponding pages in
    the kernel image map should be restored to PAGE_READ, by removing the
    PAGE_EXEC permission.
    
    This is not the case. For 64-bit kernels, only the linear map is
    restored to its proper page permissions at initmem free, and not the
    kernel image map.
    
    In practise this results in that the kernel can potentially jump to
    dead __init code, and start executing invalid instructions, without
    getting an exception.
    
    Restore the freed initmem properly, by setting both the kernel image
    map to the correct permissions.
    
    [1] Documentation/riscv/vm-layout.rst
    
    Fixes: e5c35fa04019 ("riscv: Map the kernel with correct permissions the first time")
    Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
    Reviewed-by: Alexandre Ghiti <alex@ghiti.fr>
    Tested-by: Alexandre Ghiti <alex@ghiti.fr>
    Link: https://lore.kernel.org/r/20221115090641.258476-1-bjorn@kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit deb460c36d83e85636e0f9e9a9e60957a2cea603
Author: Jisheng Zhang <jszhang@kernel.org>
Date:   Thu Nov 3 01:02:54 2022 +0800

    riscv: vdso: fix section overlapping under some conditions
    
    commit 74f6bb55c834da6d4bac24f44868202743189b2b upstream.
    
    lkp reported a build error, I tried the config and can reproduce
    build error as below:
    
      VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
    ld.lld: error: section .note file range overlaps with .text
    >>> .note range is [0x7C8, 0x803]
    >>> .text range is [0x800, 0x1993]
    
    ld.lld: error: section .text file range overlaps with .dynamic
    >>> .text range is [0x800, 0x1993]
    >>> .dynamic range is [0x808, 0x937]
    
    ld.lld: error: section .note virtual address range overlaps with .text
    >>> .note range is [0x7C8, 0x803]
    >>> .text range is [0x800, 0x1993]
    
    Fix it by setting DISABLE_BRANCH_PROFILING which will disable branch
    tracing for vdso, thus avoid useless _ftrace_annotated_branch section
    and _ftrace_branch section. Although we can also fix it by removing
    the hardcoded .text begin address, but I think that's another story
    and should be put into another patch.
    
    Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#r
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
    Link: https://lore.kernel.org/r/20221102170254.1925-1-jszhang@kernel.org
    Fixes: ad5d1122b82f ("riscv: use vDSO common flow to reduce the latency of the time-related functions")
    Cc: stable@vger.kernel.org
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a41ec58ac352fd176d5808af847663dc890f6053
Author: Yuan Can <yuancan@huawei.com>
Date:   Fri Nov 25 01:43:29 2022 +0000

    hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
    
    [ Upstream commit 9bdc112be727cf1ba65be79541147f960c3349d8 ]
    
    As the devm_kcalloc may return NULL, the return value needs to be checked
    to avoid NULL poineter dereference.
    
    Fixes: d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Link: https://lore.kernel.org/r/20221125014329.121560-1-yuancan@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f598da27acbeee414679cacd14294db3e273e3d2
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Fri Nov 18 17:33:03 2022 +0800

    hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
    
    [ Upstream commit 7dec14537c5906b8bf40fd6fd6d9c3850f8df11d ]
    
    As comment of pci_get_domain_bus_and_slot() says, it returns
    a pci device with refcount increment, when finish using it,
    the caller must decrement the reference count by calling
    pci_dev_put(). So call it after using to avoid refcount leak.
    
    Fixes: 14513ee696a0 ("hwmon: (coretemp) Use PCI host bridge ID to identify CPU if necessary")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221118093303.214163-1-yangyingliang@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ae6c8b6e5d5628df1c475c0a8fca1465e205c95b
Author: Phil Auld <pauld@redhat.com>
Date:   Thu Nov 17 11:23:13 2022 -0500

    hwmon: (coretemp) Check for null before removing sysfs attrs
    
    [ Upstream commit a89ff5f5cc64b9fe7a992cf56988fd36f56ca82a ]
    
    If coretemp_add_core() gets an error then pdata->core_data[indx]
    is already NULL and has been kfreed. Don't pass that to
    sysfs_remove_group() as that will crash in sysfs_remove_group().
    
    [Shortened for readability]
    [91854.020159] sysfs: cannot create duplicate filename '/devices/platform/coretemp.0/hwmon/hwmon2/temp20_label'
    <cpu offline>
    [91855.126115] BUG: kernel NULL pointer dereference, address: 0000000000000188
    [91855.165103] #PF: supervisor read access in kernel mode
    [91855.194506] #PF: error_code(0x0000) - not-present page
    [91855.224445] PGD 0 P4D 0
    [91855.238508] Oops: 0000 [#1] PREEMPT SMP PTI
    ...
    [91855.342716] RIP: 0010:sysfs_remove_group+0xc/0x80
    ...
    [91855.796571] Call Trace:
    [91855.810524]  coretemp_cpu_offline+0x12b/0x1dd [coretemp]
    [91855.841738]  ? coretemp_cpu_online+0x180/0x180 [coretemp]
    [91855.871107]  cpuhp_invoke_callback+0x105/0x4b0
    [91855.893432]  cpuhp_thread_fun+0x8e/0x150
    ...
    
    Fix this by checking for NULL first.
    
    Signed-off-by: Phil Auld <pauld@redhat.com>
    Cc: linux-hwmon@vger.kernel.org
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: Jean Delvare <jdelvare@suse.com>
    Cc: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20221117162313.3164803-1-pauld@redhat.com
    Fixes: 199e0de7f5df3 ("hwmon: (coretemp) Merge pkgtemp with coretemp")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c5078548c29c735f71b05053659c0cb294e738ad
Author: Marc Dionne <marc.dionne@auristor.com>
Date:   Wed Nov 30 17:55:51 2022 +0000

    afs: Fix server->active leak in afs_put_server
    
    [ Upstream commit ef4d3ea40565a781c25847e9cb96c1bd9f462bc6 ]
    
    The atomic_read was accidentally replaced with atomic_inc_return,
    which prevents the server from getting cleaned up and causes rmmod
    to hang with a warning:
    
        Can't purge s=00000001
    
    Fixes: 2757a4dc1849 ("afs: Fix access after dec in put functions")
    Signed-off-by: Marc Dionne <marc.dionne@auristor.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Link: https://lore.kernel.org/r/20221130174053.2665818-1-marc.dionne@auristor.com/
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c2885594b9b921df6ae253e151ffb648a4bbc112
Author: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Date:   Mon Nov 28 15:56:04 2022 +0900

    net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed
    
    [ Upstream commit d66233a312ec9013af3e37e4030b479a20811ec3 ]
    
    After system resumed on some environment board, the promiscuous mode
    is disabled because the SoC turned off. So, call ravb_set_rx_mode() in
    the ravb_resume() to fix the issue.
    
    Reported-by: Tho Vu <tho.vu.wh@renesas.com>
    Fixes: 0184165b2f42 ("ravb: add sleep PM suspend/resume support")
    Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
    Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
    Link: https://lore.kernel.org/r/20221128065604.1864391-1-yoshihiro.shimoda.uh@renesas.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fa20f88271259d42ebe66f0a8c4c20199e888c99
Author: Zhengchao Shao <shaozhengchao@huawei.com>
Date:   Sat Nov 26 11:17:20 2022 +0800

    sctp: fix memory leak in sctp_stream_outq_migrate()
    
    [ Upstream commit 9ed7bfc79542119ac0a9e1ce8a2a5285e43433e9 ]
    
    When sctp_stream_outq_migrate() is called to release stream out resources,
    the memory pointed to by prio_head in stream out is not released.
    
    The memory leak information is as follows:
     unreferenced object 0xffff88801fe79f80 (size 64):
       comm "sctp_repo", pid 7957, jiffies 4294951704 (age 36.480s)
       hex dump (first 32 bytes):
         80 9f e7 1f 80 88 ff ff 80 9f e7 1f 80 88 ff ff  ................
         90 9f e7 1f 80 88 ff ff 90 9f e7 1f 80 88 ff ff  ................
       backtrace:
         [<ffffffff81b215c6>] kmalloc_trace+0x26/0x60
         [<ffffffff88ae517c>] sctp_sched_prio_set+0x4cc/0x770
         [<ffffffff88ad64f2>] sctp_stream_init_ext+0xd2/0x1b0
         [<ffffffff88aa2604>] sctp_sendmsg_to_asoc+0x1614/0x1a30
         [<ffffffff88ab7ff1>] sctp_sendmsg+0xda1/0x1ef0
         [<ffffffff87f765ed>] inet_sendmsg+0x9d/0xe0
         [<ffffffff8754b5b3>] sock_sendmsg+0xd3/0x120
         [<ffffffff8755446a>] __sys_sendto+0x23a/0x340
         [<ffffffff87554651>] __x64_sys_sendto+0xe1/0x1b0
         [<ffffffff89978b49>] do_syscall_64+0x39/0xb0
         [<ffffffff89a0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    Link: https://syzkaller.appspot.com/bug?exrid=29c402e56c4760763cc0
    Fixes: 637784ade221 ("sctp: introduce priority based stream scheduler")
    Reported-by: syzbot+29c402e56c4760763cc0@syzkaller.appspotmail.com
    Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
    Reviewed-by: Xin Long <lucien.xin@gmail.com>
    Link: https://lore.kernel.org/r/20221126031720.378562-1-shaozhengchao@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 5650d521fc82ee47a81df8dd7cbe98b77fb3565a
Author: Willem de Bruijn <willemb@google.com>
Date:   Mon Nov 28 11:18:12 2022 -0500

    packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE
    
    [ Upstream commit b85f628aa158a653c006e9c1405a117baef8c868 ]
    
    CHECKSUM_COMPLETE signals that skb->csum stores the sum over the
    entire packet. It does not imply that an embedded l4 checksum
    field has been validated.
    
    Fixes: 682f048bd494 ("af_packet: pass checksum validation status to the user")
    Signed-off-by: Willem de Bruijn <willemb@google.com>
    Link: https://lore.kernel.org/r/20221128161812.640098-1-willemdebruijn.kernel@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4729c2b10c837e95365ce9a55599e23970a0f898
Author: Chris Mi <cmi@nvidia.com>
Date:   Tue Nov 29 01:30:06 2022 -0800

    net/mlx5: Lag, Fix for loop when checking lag
    
    [ Upstream commit 0e682f04b4b59eac0b0a030251513589c4607458 ]
    
    The cited commit adds a for loop to check if each port supports lag
    or not. But dev is not initialized correctly. Fix it by initializing
    dev for each iteration.
    
    Fixes: e87c6a832f88 ("net/mlx5: E-switch, Fix duplicate lag creation")
    Signed-off-by: Chris Mi <cmi@nvidia.com>
    Reported-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Link: https://lore.kernel.org/r/20221129093006.378840-2-saeed@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 4cde8da2d814a3b7b176db81922d4ddaad7c0f0e
Author: Shigeru Yoshida <syoshida@redhat.com>
Date:   Fri Nov 25 02:51:34 2022 +0900

    net: tun: Fix use-after-free in tun_detach()
    
    [ Upstream commit 5daadc86f27ea4d691e2131c04310d0418c6cd12 ]
    
    syzbot reported use-after-free in tun_detach() [1].  This causes call
    trace like below:
    
    ==================================================================
    BUG: KASAN: use-after-free in notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
    Read of size 8 at addr ffff88807324e2a8 by task syz-executor.0/3673
    
    CPU: 0 PID: 3673 Comm: syz-executor.0 Not tainted 6.1.0-rc5-syzkaller-00044-gcc675d22e422 #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
     print_address_description mm/kasan/report.c:284 [inline]
     print_report+0x15e/0x461 mm/kasan/report.c:395
     kasan_report+0xbf/0x1f0 mm/kasan/report.c:495
     notifier_call_chain+0x1ee/0x200 kernel/notifier.c:75
     call_netdevice_notifiers_info+0x86/0x130 net/core/dev.c:1942
     call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
     call_netdevice_notifiers net/core/dev.c:1997 [inline]
     netdev_wait_allrefs_any net/core/dev.c:10237 [inline]
     netdev_run_todo+0xbc6/0x1100 net/core/dev.c:10351
     tun_detach drivers/net/tun.c:704 [inline]
     tun_chr_close+0xe4/0x190 drivers/net/tun.c:3467
     __fput+0x27c/0xa90 fs/file_table.c:320
     task_work_run+0x16f/0x270 kernel/task_work.c:179
     exit_task_work include/linux/task_work.h:38 [inline]
     do_exit+0xb3d/0x2a30 kernel/exit.c:820
     do_group_exit+0xd4/0x2a0 kernel/exit.c:950
     get_signal+0x21b1/0x2440 kernel/signal.c:2858
     arch_do_signal_or_restart+0x86/0x2300 arch/x86/kernel/signal.c:869
     exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
     exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
     __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
     syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296
     do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
     entry_SYSCALL_64_after_hwframe+0x63/0xcd
    
    The cause of the issue is that sock_put() from __tun_detach() drops
    last reference count for struct net, and then notifier_call_chain()
    from netdev_state_change() accesses that struct net.
    
    This patch fixes the issue by calling sock_put() from tun_detach()
    after all necessary accesses for the struct net has done.
    
    Fixes: 83c1f36f9880 ("tun: send netlink notification when the device is modified")
    Reported-by: syzbot+106f9b687cd64ee70cd1@syzkaller.appspotmail.com
    Link: https://syzkaller.appspot.com/bug?id=96eb7f1ce75ef933697f24eeab928c4a716edefe [1]
    Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
    Link: https://lore.kernel.org/r/20221124175134.1589053-1-syoshida@redhat.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 05cf72a0a5252d7cdd5a4f63bd44e937bc55b452
Author: David Howells <dhowells@redhat.com>
Date:   Mon Nov 28 22:02:56 2022 +0000

    afs: Fix fileserver probe RTT handling
    
    [ Upstream commit ca57f02295f188d6c65ec02202402979880fa6d8 ]
    
    The fileserver probing code attempts to work out the best fileserver to
    use for a volume by retrieving the RTT calculated by AF_RXRPC for the
    probe call sent to each server and comparing them.  Sometimes, however,
    no RTT estimate is available and rxrpc_kernel_get_srtt() returns false,
    leading good fileservers to be given an RTT of UINT_MAX and thus causing
    the rotation algorithm to ignore them.
    
    Fix afs_select_fileserver() to ignore rxrpc_kernel_get_srtt()'s return
    value and just take the estimated RTT it provides - which will be capped
    at 1 second.
    
    Fixes: 1d4adfaf6574 ("rxrpc: Make rxrpc_kernel_get_srtt() indicate validity")
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
    Tested-by: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Link: https://lore.kernel.org/r/166965503999.3392585.13954054113218099395.stgit@warthog.procyon.org.uk/
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2708b357440427d6a9fee667eb7b8307f4625adc
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Thu Nov 24 23:01:30 2022 +0800

    net: mdiobus: fix unbalanced node reference count
    
    [ Upstream commit cdde1560118f82498fc9e9a7c1ef7f0ef7755891 ]
    
    I got the following report while doing device(mscc-miim) load test
    with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
    
      OF: ERROR: memory leak, expected refcount 1 instead of 2,
      of_node_get()/of_node_put() unbalanced - destroy cset entry:
      attach overlay node /spi/soc@0/mdio@7107009c/ethernet-phy@0
    
    If the 'fwnode' is not an acpi node, the refcount is get in
    fwnode_mdiobus_phy_device_register(), but it has never been
    put when the device is freed in the normal path. So call
    fwnode_handle_put() in phy_device_release() to avoid leak.
    
    If it's an acpi node, it has never been get, but it's put
    in the error path, so call fwnode_handle_get() before
    phy_device_register() to keep get/put operation balanced.
    
    Fixes: bc1bee3b87ee ("net: mdiobus: Introduce fwnode_mdiobus_register_phy()")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Link: https://lore.kernel.org/r/20221124150130.609420-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f3add2b8cf620966de3ebfa07679ca12d33ec26f
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Fri Nov 25 15:57:24 2022 +0800

    net: hsr: Fix potential use-after-free
    
    [ Upstream commit 7e177d32442b7ed08a9fa61b61724abc548cb248 ]
    
    The skb is delivered to netif_rx() which may free it, after calling this,
    dereferencing skb may trigger use-after-free.
    
    Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Link: https://lore.kernel.org/r/20221125075724.27912-1-yuehaibing@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e128190adb2edfd5042105b5d1ed4553f295f5ef
Author: Xin Long <lucien.xin@gmail.com>
Date:   Fri Nov 25 12:46:43 2022 -0500

    tipc: re-fetch skb cb after tipc_msg_validate
    
    [ Upstream commit 3067bc61fcfe3081bf4807ce65560f499e895e77 ]
    
    As the call trace shows, the original skb was freed in tipc_msg_validate(),
    and dereferencing the old skb cb would cause an use-after-free crash.
    
      BUG: KASAN: use-after-free in tipc_crypto_rcv_complete+0x1835/0x2240 [tipc]
      Call Trace:
       <IRQ>
       tipc_crypto_rcv_complete+0x1835/0x2240 [tipc]
       tipc_crypto_rcv+0xd32/0x1ec0 [tipc]
       tipc_rcv+0x744/0x1150 [tipc]
      ...
      Allocated by task 47078:
       kmem_cache_alloc_node+0x158/0x4d0
       __alloc_skb+0x1c1/0x270
       tipc_buf_acquire+0x1e/0xe0 [tipc]
       tipc_msg_create+0x33/0x1c0 [tipc]
       tipc_link_build_proto_msg+0x38a/0x2100 [tipc]
       tipc_link_timeout+0x8b8/0xef0 [tipc]
       tipc_node_timeout+0x2a1/0x960 [tipc]
       call_timer_fn+0x2d/0x1c0
      ...
      Freed by task 47078:
       tipc_msg_validate+0x7b/0x440 [tipc]
       tipc_crypto_rcv_complete+0x4b5/0x2240 [tipc]
       tipc_crypto_rcv+0xd32/0x1ec0 [tipc]
       tipc_rcv+0x744/0x1150 [tipc]
    
    This patch fixes it by re-fetching the skb cb from the new allocated skb
    after calling tipc_msg_validate().
    
    Fixes: fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
    Reported-by: Shuang Li <shuali@redhat.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Link: https://lore.kernel.org/r/1b1cdba762915325bd8ef9a98d0276eb673df2a5.1669398403.git.lucien.xin@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d8e6c5500dbf0f3e87aace90d4beba6ae928e866
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Mon Nov 28 16:42:38 2022 +0100

    mptcp: fix sleep in atomic at close time
    
    [ Upstream commit b4f166651d03b5484fa179817ba8ad4899a5a6ac ]
    
    Matt reported a splat at msk close time:
    
        BUG: sleeping function called from invalid context at net/mptcp/protocol.c:2877
        in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 155, name: packetdrill
        preempt_count: 201, expected: 0
        RCU nest depth: 0, expected: 0
        4 locks held by packetdrill/155:
        #0: ffff888001536990 (&sb->s_type->i_mutex_key#6){+.+.}-{3:3}, at: __sock_release (net/socket.c:650)
        #1: ffff88800b498130 (sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_close (net/mptcp/protocol.c:2973)
        #2: ffff88800b49a130 (sk_lock-AF_INET/1){+.+.}-{0:0}, at: __mptcp_close_ssk (net/mptcp/protocol.c:2363)
        #3: ffff88800b49a0b0 (slock-AF_INET){+...}-{2:2}, at: __lock_sock_fast (include/net/sock.h:1820)
        Preemption disabled at:
        0x0
        CPU: 1 PID: 155 Comm: packetdrill Not tainted 6.1.0-rc5 #365
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
        Call Trace:
        <TASK>
        dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))
        __might_resched.cold (kernel/sched/core.c:9891)
        __mptcp_destroy_sock (include/linux/kernel.h:110)
        __mptcp_close (net/mptcp/protocol.c:2959)
        mptcp_subflow_queue_clean (include/net/sock.h:1777)
        __mptcp_close_ssk (net/mptcp/protocol.c:2363)
        mptcp_destroy_common (net/mptcp/protocol.c:3170)
        mptcp_destroy (include/net/sock.h:1495)
        __mptcp_destroy_sock (net/mptcp/protocol.c:2886)
        __mptcp_close (net/mptcp/protocol.c:2959)
        mptcp_close (net/mptcp/protocol.c:2974)
        inet_release (net/ipv4/af_inet.c:432)
        __sock_release (net/socket.c:651)
        sock_close (net/socket.c:1367)
        __fput (fs/file_table.c:320)
        task_work_run (kernel/task_work.c:181 (discriminator 1))
        exit_to_user_mode_prepare (include/linux/resume_user_mode.h:49)
        syscall_exit_to_user_mode (kernel/entry/common.c:130)
        do_syscall_64 (arch/x86/entry/common.c:87)
        entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
    
    We can't call mptcp_close under the 'fast' socket lock variant, replace
    it with a sock_lock_nested() as the relevant code is already under the
    listening msk socket lock protection.
    
    Reported-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/316
    Fixes: 30e51b923e43 ("mptcp: fix unreleased socket in accept queue")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 268b5f3cfff59978a764a17da064aa4dcbf3ed4f
Author: Menglong Dong <imagedong@tencent.com>
Date:   Mon Nov 28 16:42:37 2022 +0100

    mptcp: don't orphan ssk in mptcp_close()
    
    [ Upstream commit fe94800184f22d4778628f1321dce5acb7513d84 ]
    
    All of the subflows of a msk will be orphaned in mptcp_close(), which
    means the subflows are in DEAD state. After then, DATA_FIN will be sent,
    and the other side will response with a DATA_ACK for this DATA_FIN.
    
    However, if the other side still has pending data, the data that received
    on these subflows will not be passed to the msk, as they are DEAD and
    subflow_data_ready() will not be called in tcp_data_ready(). Therefore,
    these data can't be acked, and they will be retransmitted again and again,
    until timeout.
    
    Fix this by setting ssk->sk_socket and ssk->sk_wq to 'NULL', instead of
    orphaning the subflows in __mptcp_close(), as Paolo suggested.
    
    Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close")
    Reviewed-by: Biao Jiang <benbjiang@tencent.com>
    Reviewed-by: Mengen Sun <mengensun@tencent.com>
    Signed-off-by: Menglong Dong <imagedong@tencent.com>
    Reviewed-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 92172e4b37e6390f47c80e22bb6f7a0250595d23
Author: Jerry Ray <jerry.ray@microchip.com>
Date:   Mon Nov 28 13:35:59 2022 -0600

    dsa: lan9303: Correct stat name
    
    [ Upstream commit 39f59bca275d2d819a8788c0f962e9e89843efc9 ]
    
    This patch changes the reported ethtool statistics for the lan9303
    family of parts covered by this driver.
    
    The TxUnderRun statistic label is renamed to RxShort to accurately
    reflect what stat the device is reporting.  I did not reorder the
    statistics as that might cause problems with existing user code that
    are expecting the stats at a certain offset.
    
    Fixes: a1292595e006 ("net: dsa: add new DSA switch driver for the SMSC-LAN9303")
    Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
    Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/20221128193559.6572-1-jerry.ray@microchip.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit fdfacd7c79d25ffa2c8950afd6e740e95cf058bb
Author: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
Date:   Thu Nov 24 16:08:32 2022 +0530

    net: wwan: iosm: fix incorrect skb length
    
    [ Upstream commit c34ca4f32c24bf748493b49085e43cd714cf8357 ]
    
    skb passed to network layer contains incorrect length.
    
    In mux aggregation protocol, the datagram block received
    from device contains block signature, packet & datagram
    header. The right skb len to be calculated by subracting
    datagram pad len from datagram length.
    
    Whereas in mux lite protocol, the skb contains single
    datagram so skb len is calculated by subtracting the
    packet offset from datagram header.
    
    Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
    Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 20be3364c5270eb29d7fed71b583c196402b3a8a
Author: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
Date:   Thu Nov 24 16:08:17 2022 +0530

    net: wwan: iosm: fix crash in peek throughput test
    
    [ Upstream commit 2290a1d46bf30f9e0bcf49ad20d5c30d0e099989 ]
    
    Peek throughput UL test is resulting in crash. If the UL
    transfer block free list is exhaust, the peeked skb is freed.
    In the next transfer freed skb is referred from UL list which
    results in crash.
    
    Don't free the skb if UL transfer blocks are unavailable. The
    pending skb will be picked for transfer on UL transfer block
    available.
    
    Fixes: 1f52d7b62285 ("net: wwan: iosm: Enable M.2 7360 WWAN card support")
    Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7d68b73349e3c9c9e05f48882ca0a7bf9aed80b4
Author: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
Date:   Thu Nov 24 16:08:03 2022 +0530

    net: wwan: iosm: fix dma_alloc_coherent incompatible pointer type
    
    [ Upstream commit 4a99e3c8ed888577b947cbed97d88c9706896105 ]
    
    Fix build error reported on armhf while preparing 6.1-rc5
    for Debian.
    
    iosm_ipc_protocol.c:244:36: error: passing argument 3 of
    'dma_alloc_coherent' from incompatible pointer type.
    
    Change phy_ap_shm type from phys_addr_t to dma_addr_t.
    
    Fixes: faed4c6f6f48 ("net: iosm: shared memory protocol")
    Reported-by: Bonaccorso Salvatore <carnil@debian.org>
    Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c439cfadfc2925b94d6f334f57bf8594bcf02f76
Author: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
Date:   Thu Nov 24 16:07:46 2022 +0530

    net: wwan: iosm: fix kernel test robot reported error
    
    [ Upstream commit 985a02e75881b73a43c9433a718b49d272a9dd6b ]
    
    sparse warnings - iosm_ipc_mux_codec.c:1474 using plain
    integer as NULL pointer.
    
    Use skb_trim() to reset skb tail & len.
    
    Fixes: 9413491e20e1 ("net: iosm: encode or decode datagram")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: M Chetan Kumar <m.chetan.kumar@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 80e82f7b440b65cf131dce10f487dc73a7046e6b
Author: Yuri Karpov <YKarpov@ispras.ru>
Date:   Thu Nov 24 11:43:03 2022 +0300

    net: ethernet: nixge: fix NULL dereference
    
    [ Upstream commit 9256db4e45e8b497b0e993cc3ed4ad08eb2389b6 ]
    
    In function nixge_hw_dma_bd_release() dereference of NULL pointer
    priv->rx_bd_v is possible for the case of its allocation failure in
    nixge_hw_dma_bd_init().
    
    Move for() loop with priv->rx_bd_v dereference under the check for
    its validity.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
    Signed-off-by: Yuri Karpov <YKarpov@ispras.ru>
    Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit aa08323fe18cb7cf95317ffa2d54ca1de8e74ebd
Author: Wang Hai <wanghai38@huawei.com>
Date:   Thu Nov 24 16:10:05 2022 +0800

    net/9p: Fix a potential socket leak in p9_socket_open
    
    [ Upstream commit dcc14cfd7debe11b825cb077e75d91d2575b4cb8 ]
    
    Both p9_fd_create_tcp() and p9_fd_create_unix() will call
    p9_socket_open(). If the creation of p9_trans_fd fails,
    p9_fd_create_tcp() and p9_fd_create_unix() will return an
    error directly instead of releasing the cscoket, which will
    result in a socket leak.
    
    This patch adds sock_release() to fix the leak issue.
    
    Fixes: 6b18662e239a ("9p connect fixes")
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    ACKed-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 542635f7d71b2f60b853467f7061343b0a05caa9
Author: Yuan Can <yuancan@huawei.com>
Date:   Thu Nov 24 07:09:17 2022 +0000

    net: net_netdev: Fix error handling in ntb_netdev_init_module()
    
    [ Upstream commit b8f79dccd38edf7db4911c353d9cd792ab13a327 ]
    
    The ntb_netdev_init_module() returns the ntb_transport_register_client()
    directly without checking its return value, if
    ntb_transport_register_client() failed, the NTB client device is not
    unregistered.
    
    Fix by unregister NTB client device when ntb_transport_register_client()
    failed.
    
    Fixes: 548c237c0a99 ("net: Add support for NTB virtual ethernet device")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e4ae9786545b6c4e8604fefd71e19c97abfe8134
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Thu Nov 24 11:03:08 2022 +0800

    net: ethernet: ti: am65-cpsw: fix error handling in am65_cpsw_nuss_probe()
    
    [ Upstream commit 46fb6512538d201d9a5b2bd7138b6751c37fdf0b ]
    
    The am65_cpsw_nuss_cleanup_ndev() function calls unregister_netdev()
    even if register_netdev() fails, which triggers WARN_ON(1) in
    unregister_netdevice_many(). To fix it, make sure that
    unregister_netdev() is called only on registered netdev.
    
    Compile tested only.
    
    Fixes: 84b4aa493249 ("net: ethernet: ti: am65-cpsw: add multi port support in mac-only mode")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit eaa5722549ac2604ffa56c2e946acc83226f130c
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Wed Nov 23 21:28:08 2022 +0800

    net: phy: fix null-ptr-deref while probe() failed
    
    [ Upstream commit 369eb2c9f1f72adbe91e0ea8efb130f0a2ba11a6 ]
    
    I got a null-ptr-deref report as following when doing fault injection test:
    
    BUG: kernel NULL pointer dereference, address: 0000000000000058
    Oops: 0000 [#1] PREEMPT SMP KASAN PTI
    CPU: 1 PID: 253 Comm: 507-spi-dm9051 Tainted: G    B            N 6.1.0-rc3+
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
    RIP: 0010:klist_put+0x2d/0xd0
    Call Trace:
     <TASK>
     klist_remove+0xf1/0x1c0
     device_release_driver_internal+0x23e/0x2d0
     bus_remove_device+0x1bd/0x240
     device_del+0x357/0x770
     phy_device_remove+0x11/0x30
     mdiobus_unregister+0xa5/0x140
     release_nodes+0x6a/0xa0
     devres_release_all+0xf8/0x150
     device_unbind_cleanup+0x19/0xd0
    
    //probe path:
    phy_device_register()
      device_add()
    
    phy_connect
      phy_attach_direct() //set device driver
        probe() //it's failed, driver is not bound
        device_bind_driver() // probe failed, it's not called
    
    //remove path:
    phy_device_remove()
      device_del()
        device_release_driver_internal()
          __device_release_driver() //dev->drv is not NULL
            klist_remove() <- knode_driver is not added yet, cause null-ptr-deref
    
    In phy_attach_direct(), after setting the 'dev->driver', probe() fails,
    device_bind_driver() is not called, so the knode_driver->n_klist is not
    set, then it causes null-ptr-deref in __device_release_driver() while
    deleting device. Fix this by setting dev->driver to NULL in the error
    path in phy_attach_direct().
    
    Fixes: e13934563db0 ("[PATCH] PHY Layer fixup")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f0fcad4c7201ecfaa17357f4ce0c50b4708df22d
Author: Lorenzo Bianconi <lorenzo@kernel.org>
Date:   Tue Nov 8 16:19:26 2022 +0100

    wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration
    
    [ Upstream commit 3e8f7abcc3473bc9603323803aeaed4ffcc3a2ab ]
    
    Fix possible out-of-bound access in ieee80211_get_rate_duration routine
    as reported by the following UBSAN report:
    
    UBSAN: array-index-out-of-bounds in net/mac80211/airtime.c:455:47
    index 15 is out of range for type 'u16 [12]'
    CPU: 2 PID: 217 Comm: kworker/u32:10 Not tainted 6.1.0-060100rc3-generic
    Hardware name: Acer Aspire TC-281/Aspire TC-281, BIOS R01-A2 07/18/2017
    Workqueue: mt76 mt76u_tx_status_data [mt76_usb]
    Call Trace:
     <TASK>
     show_stack+0x4e/0x61
     dump_stack_lvl+0x4a/0x6f
     dump_stack+0x10/0x18
     ubsan_epilogue+0x9/0x43
     __ubsan_handle_out_of_bounds.cold+0x42/0x47
    ieee80211_get_rate_duration.constprop.0+0x22f/0x2a0 [mac80211]
     ? ieee80211_tx_status_ext+0x32e/0x640 [mac80211]
     ieee80211_calc_rx_airtime+0xda/0x120 [mac80211]
     ieee80211_calc_tx_airtime+0xb4/0x100 [mac80211]
     mt76x02_send_tx_status+0x266/0x480 [mt76x02_lib]
     mt76x02_tx_status_data+0x52/0x80 [mt76x02_lib]
     mt76u_tx_status_data+0x67/0xd0 [mt76_usb]
     process_one_work+0x225/0x400
     worker_thread+0x50/0x3e0
     ? process_one_work+0x400/0x400
     kthread+0xe9/0x110
     ? kthread_complete_and_exit+0x20/0x20
     ret_from_fork+0x22/0x30
    
    Fixes: db3e1c40cf2f ("mac80211: Import airtime calculation code from mt76")
    Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
    Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 31068288eaf01824d59a9eb926912fc9e1564a36
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Nov 25 12:36:58 2022 +0100

    wifi: cfg80211: don't allow multi-BSSID in S1G
    
    [ Upstream commit acd3c92acc7aaec50a94d0a7faf7ccd74e952493 ]
    
    In S1G beacon frames there shouldn't be multi-BSSID elements
    since that's not supported, remove that to avoid a potential
    integer underflow and/or misparsing the frames due to the
    different length of the fixed part of the frame.
    
    While at it, initialize non_tx_data so we don't send garbage
    values to the user (even if it doesn't seem to matter now.)
    
    Reported-and-tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
    Fixes: 9eaffe5078ca ("cfg80211: convert S1G beacon to scan results")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 391cb872553627bdcf236c03ee7d5adb275e37e1
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Nov 25 12:36:57 2022 +0100

    wifi: cfg80211: fix buffer overflow in elem comparison
    
    [ Upstream commit 9f16b5c82a025cd4c864737409234ddc44fb166a ]
    
    For vendor elements, the code here assumes that 5 octets
    are present without checking. Since the element itself is
    already checked to fit, we only need to check the length.
    
    Reported-and-tested-by: Sönke Huster <shuster@seemoo.tu-darmstadt.de>
    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 34cbc950d02eaf480a128787cb726c513462ef60
Author: Izabela Bakollari <ibakolla@redhat.com>
Date:   Wed Nov 23 11:10:08 2022 +0100

    aquantia: Do not purge addresses when setting the number of rings
    
    [ Upstream commit 2a83891130512dafb321418a8e7c9c09268d8c59 ]
    
    IPV6 addresses are purged when setting the number of rx/tx
    rings using ethtool -G. The function aq_set_ringparam
    calls dev_close, which removes the addresses. As a solution,
    call an internal function (aq_ndev_close).
    
    Fixes: c1af5427954b ("net: aquantia: Ethtool based ring size configuration")
    Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit da417542faec3618c8c4def983ddfe698d96a55b
Author: Duoming Zhou <duoming@zju.edu.cn>
Date:   Wed Nov 23 18:06:42 2022 +0800

    qlcnic: fix sleep-in-atomic-context bugs caused by msleep
    
    [ Upstream commit 8dbd6e4ce1b9c527921643d9e34f188a10d4e893 ]
    
    The watchdog timer is used to monitor whether the process
    of transmitting data is timeout. If we use qlcnic driver,
    the dev_watchdog() that is the timer handler of watchdog
    timer will call qlcnic_tx_timeout() to process the timeout.
    But the qlcnic_tx_timeout() calls msleep(), as a result,
    the sleep-in-atomic-context bugs will happen. The processes
    are shown below:
    
       (atomic context)
    dev_watchdog
      qlcnic_tx_timeout
        qlcnic_83xx_idc_request_reset
          qlcnic_83xx_lock_driver
            msleep
    
    ---------------------------
    
       (atomic context)
    dev_watchdog
      qlcnic_tx_timeout
        qlcnic_83xx_idc_request_reset
          qlcnic_83xx_lock_driver
            qlcnic_83xx_recover_driver_lock
              msleep
    
    Fix by changing msleep() to mdelay(), the mdelay() is
    busy-waiting and the bugs could be mitigated.
    
    Fixes: 629263acaea3 ("qlcnic: 83xx CNA inter driver communication mechanism")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b9cc64cf0d11f74419f1dc1e9778481cfeee5e1c
Author: Amir Goldstein <amir73il@gmail.com>
Date:   Thu Nov 17 22:52:49 2022 +0200

    vfs: fix copy_file_range() averts filesystem freeze protection
    
    [ Upstream commit 10bc8e4af65946b727728d7479c028742321b60a ]
    
    Commit 868f9f2f8e00 ("vfs: fix copy_file_range() regression in cross-fs
    copies") removed fallback to generic_copy_file_range() for cross-fs
    cases inside vfs_copy_file_range().
    
    To preserve behavior of nfsd and ksmbd server-side-copy, the fallback to
    generic_copy_file_range() was added in nfsd and ksmbd code, but that
    call is missing sb_start_write(), fsnotify hooks and more.
    
    Ideally, nfsd and ksmbd would pass a flag to vfs_copy_file_range() that
    will take care of the fallback, but that code would be subtle and we got
    vfs_copy_file_range() logic wrong too many times already.
    
    Instead, add a flag to explicitly request vfs_copy_file_range() to
    perform only generic_copy_file_range() and let nfsd and ksmbd use this
    flag only in the fallback path.
    
    This choise keeps the logic changes to minimum in the non-nfsd/ksmbd code
    paths to reduce the risk of further regressions.
    
    Fixes: 868f9f2f8e00 ("vfs: fix copy_file_range() regression in cross-fs copies")
    Tested-by: Namjae Jeon <linkinjeon@kernel.org>
    Tested-by: Luis Henriques <lhenriques@suse.de>
    Signed-off-by: Amir Goldstein <amir73il@gmail.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 534d49784592ee3032e9c005d171d55734f25356
Author: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Date:   Wed Nov 23 14:36:51 2022 +0800

    can: m_can: Add check for devm_clk_get
    
    [ Upstream commit 68b4f9e0bdd0f920d7303d07bfe226cd0976961d ]
    
    Since the devm_clk_get may return error,
    it should be better to add check for the cdev->hclk,
    as same as cdev->cclk.
    
    Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Link: https://lore.kernel.org/all/20221123063651.26199-1-jiasheng@iscas.ac.cn
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0bbb88651ef6b7fbb1bf75ec7ba69add632e834b
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Fri Nov 11 20:11:23 2022 +0800

    can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods
    
    [ Upstream commit 1eca1d4cc21b6d0fc5f9a390339804c0afce9439 ]
    
    In m_can_pci_remove() and error handling path of m_can_pci_probe(),
    m_can_class_free_dev() should be called to free resource allocated by
    m_can_class_allocate_dev(), otherwise there will be memleak.
    
    Fixes: cab7ffc0324f ("can: m_can: add PCI glue driver for Intel Elkhart Lake")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Link: https://lore.kernel.org/all/1668168684-6390-1-git-send-email-zhangchangzhong@huawei.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d44fd8bdfc04c671cdf3fe9447098c9e40e41208
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Mon Nov 14 16:14:44 2022 +0800

    can: etas_es58x: es58x_init_netdev(): free netdev when register_candev()
    
    [ Upstream commit 709cb2f9ed2006eb1dc4b36b99d601cd24889ec4 ]
    
    In case of register_candev() fails, clear
    es58x_dev->netdev[channel_idx] and add free_candev(). Otherwise
    es58x_free_netdevs() will unregister the netdev that has never been
    registered.
    
    Fixes: 8537257874e9 ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Acked-by: Arunachalam Santhanam <Arunachalam.Santhanam@in.bosch.com>
    Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
    Link: https://lore.kernel.org/all/1668413685-23354-1-git-send-email-zhangchangzhong@huawei.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 260122778b77fabcb522f9437003dee01518e659
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Fri Nov 11 20:09:16 2022 +0800

    can: cc770: cc770_isa_probe(): add missing free_cc770dev()
    
    [ Upstream commit 62ec89e74099a3d6995988ed9f2f996b368417ec ]
    
    Add the missing free_cc770dev() before return from cc770_isa_probe()
    in the register_cc770dev() error handling case.
    
    In addition, remove blanks before goto labels.
    
    Fixes: 7e02e5433e00 ("can: cc770: legacy CC770 ISA bus driver")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Link: https://lore.kernel.org/all/1668168557-6024-1-git-send-email-zhangchangzhong@huawei.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 9cc7e8a216e3f7b459d0efb9b2a8d4e104ed49e2
Author: Zhang Changzhong <zhangchangzhong@huawei.com>
Date:   Fri Nov 11 20:08:41 2022 +0800

    can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev()
    
    [ Upstream commit 92dfd9310a71d28cefe6a2d5174d43fab240e631 ]
    
    Add the missing free_sja1000dev() before return from
    sja1000_isa_probe() in the register_sja1000dev() error handling case.
    
    In addition, remove blanks before goto labels.
    
    Fixes: 2a6ba39ad6a2 ("can: sja1000: legacy SJA1000 ISA bus driver")
    Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
    Link: https://lore.kernel.org/all/1668168521-5540-1-git-send-email-zhangchangzhong@huawei.com
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e6d2d26a49c3a9cd46b232975e45236304810904
Author: Roi Dayan <roid@nvidia.com>
Date:   Mon Nov 14 20:04:29 2022 +0200

    net/mlx5e: Fix use-after-free when reverting termination table
    
    [ Upstream commit 52c795af04441d76f565c4634f893e5b553df2ae ]
    
    When having multiple dests with termination tables and second one
    or afterwards fails the driver reverts usage of term tables but
    doesn't reset the assignment in attr->dests[num_vport_dests].termtbl
    which case a use-after-free when releasing the rule.
    Fix by resetting the assignment of termtbl to null.
    
    Fixes: 10caabdaad5a ("net/mlx5e: Use termination table for VLAN push actions")
    Signed-off-by: Roi Dayan <roid@nvidia.com>
    Reviewed-by: Maor Dickman <maord@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 61a5df358dc32fa758b5b71a80d03c9ab823d915
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Mon Nov 21 19:22:04 2022 +0800

    net/mlx5: Fix uninitialized variable bug in outlen_write()
    
    [ Upstream commit 3f5769a074c13d8f08455e40586600419e02a880 ]
    
    If sscanf() return 0, outlen is uninitialized and used in kzalloc(),
    this is unexpected. We should return -EINVAL if the string is invalid.
    
    Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters")
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 401dd80091ee7a5d8eb3a68782515f91d5bfdc85
Author: Chris Mi <cmi@nvidia.com>
Date:   Thu Aug 4 05:09:07 2022 +0300

    net/mlx5: E-switch, Fix duplicate lag creation
    
    [ Upstream commit e87c6a832f889c093c055a30a7b8c6843e6573bf ]
    
    If creating bond first and then enabling sriov in switchdev mode,
    will hit the following syndrome:
    
    mlx5_core 0000:08:00.0: mlx5_cmd_out_err:778:(pid 25543): CREATE_LAG(0x840) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x7d49cb), err(-22)
    
    The reason is because the offending patch removes eswitch mode
    none. In vf lag, the checking of eswitch mode none is replaced
    by checking if sriov is enabled. But when driver enables sriov,
    it triggers the bond workqueue task first and then setting sriov
    number in pci_enable_sriov(). So the check fails.
    
    Fix it by checking if sriov is enabled using eswitch internal
    counter that is set before triggering the bond workqueue task.
    
    Fixes: f019679ea5f2 ("net/mlx5: E-switch, Remove dependency between sriov and eswitch mode")
    Signed-off-by: Chris Mi <cmi@nvidia.com>
    Reviewed-by: Roi Dayan <roid@nvidia.com>
    Reviewed-by: Mark Bloch <mbloch@nvidia.com>
    Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e9a2ac40b5d42df2db6bedba18b713605c1215e2
Author: Chris Mi <cmi@nvidia.com>
Date:   Thu Nov 17 09:48:13 2022 +0200

    net/mlx5: E-switch, Destroy legacy fdb table when needed
    
    [ Upstream commit 2318b8bb94a3a21363cd0d49cad5934bd1e2d60e ]
    
    The cited commit removes eswitch mode none. But when disabling
    sriov in legacy mode or changing from switchdev to legacy mode
    without sriov enabled, the legacy fdb table is not destroyed.
    
    It is not the right behavior. Destroy legacy fdb table in above
    two caes.
    
    Fixes: f019679ea5f2 ("net/mlx5: E-switch, Remove dependency between sriov and eswitch mode")
    Signed-off-by: Chris Mi <cmi@nvidia.com>
    Reviewed-by: Roi Dayan <roid@nvidia.com>
    Reviewed-by: Eli Cohen <elic@nvidia.com>
    Reviewed-by: Mark Bloch <mbloch@nvidia.com>
    Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 70299a7027a273dbdc2d443d4a27e92ae628d640
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Thu Nov 10 21:47:07 2022 +0800

    net/mlx5: DR, Fix uninitialized var warning
    
    [ Upstream commit 52f7cf70eb8fac6111786c59ae9dfc5cf2bee710 ]
    
    Smatch warns this:
    
    drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
     mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
    
    Initializing ret with -EOPNOTSUPP and fix missing action case.
    
    Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality")
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Reviewed-by: Roi Dayan <roid@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b46f6144ab89d3d757ead940759c505091626a7d
Author: Wang Hai <wanghai38@huawei.com>
Date:   Wed Nov 16 01:24:07 2022 +0800

    e100: Fix possible use after free in e100_xmit_prepare
    
    [ Upstream commit 45605c75c52c7ae7bfe902214343aabcfe5ba0ff ]
    
    In e100_xmit_prepare(), if we can't map the skb, then return -ENOMEM, so
    e100_xmit_frame() will return NETDEV_TX_BUSY and the upper layer will
    resend the skb. But the skb is already freed, which will cause UAF bug
    when the upper layer resends the skb.
    
    Remove the harmful free.
    
    Fixes: 5e5d49422dfb ("e100: Release skb when DMA mapping is failed in e100_xmit_prepare")
    Signed-off-by: Wang Hai <wanghai38@huawei.com>
    Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bd477b891a4fa084561234eed4afacb3001dd359
Author: Yuan Can <yuancan@huawei.com>
Date:   Mon Nov 14 08:26:40 2022 +0000

    iavf: Fix error handling in iavf_init_module()
    
    [ Upstream commit 227d8d2f7f2278b8468c5531b0cd0f2a905b4486 ]
    
    The iavf_init_module() won't destroy workqueue when pci_register_driver()
    failed. Call destroy_workqueue() when pci_register_driver() failed to
    prevent the resource leak.
    
    Similar to the handling of u132_hcd_init in commit f276e002793c
    ("usb: u132-hcd: fix resource leak")
    
    Fixes: 2803b16c10ea ("i40e/i40evf: Use private workqueue")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 6313cf0f212fb3cf52f99369f3f4f48fa708a487
Author: Yuan Can <yuancan@huawei.com>
Date:   Mon Nov 14 08:26:39 2022 +0000

    fm10k: Fix error handling in fm10k_init_module()
    
    [ Upstream commit 771a794c0a3c3e7f0d86cc34be4f9537e8c0a20c ]
    
    A problem about modprobe fm10k failed is triggered with the following log
    given:
    
     Intel(R) Ethernet Switch Host Interface Driver
     Copyright(c) 2013 - 2019 Intel Corporation.
     debugfs: Directory 'fm10k' with parent '/' already present!
    
    The reason is that fm10k_init_module() returns fm10k_register_pci_driver()
    directly without checking its return value, if fm10k_register_pci_driver()
    failed, it returns without removing debugfs and destroy workqueue,
    resulting the debugfs of fm10k can never be created later and leaks the
    workqueue.
    
     fm10k_init_module()
       alloc_workqueue()
       fm10k_dbg_init() # create debugfs
       fm10k_register_pci_driver()
         pci_register_driver()
           driver_register()
             bus_add_driver()
               priv = kzalloc(...) # OOM happened
       # return without remove debugfs and destroy workqueue
    
    Fix by remove debugfs and destroy workqueue when
    fm10k_register_pci_driver() returns error.
    
    Fixes: 7461fd913afe ("fm10k: Add support for debugfs")
    Fixes: b382bb1b3e2d ("fm10k: use separate workqueue for fm10k driver")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 7fba35dda6812f8d06d3e3af14f287054322686a
Author: Shang XiaoJing <shangxiaojing@huawei.com>
Date:   Wed Nov 16 09:27:25 2022 +0800

    i40e: Fix error handling in i40e_init_module()
    
    [ Upstream commit 479dd06149425b9e00477f52200872587af76a48 ]
    
    i40e_init_module() won't free the debugfs directory created by
    i40e_dbg_init() when pci_register_driver() failed. Add fail path to
    call i40e_dbg_exit() to remove the debugfs entries to prevent the bug.
    
    i40e: Intel(R) Ethernet Connection XL710 Network Driver
    i40e: Copyright (c) 2013 - 2019 Intel Corporation.
    debugfs: Directory 'i40e' with parent '/' already present!
    
    Fixes: 41c445ff0f48 ("i40e: main driver core")
    Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c99671d4699dcf90d6939923c8fe8a8918e140b2
Author: Shang XiaoJing <shangxiaojing@huawei.com>
Date:   Mon Nov 14 10:57:58 2022 +0800

    ixgbevf: Fix resource leak in ixgbevf_init_module()
    
    [ Upstream commit 8cfa238a48f34038464b99d0b4825238c2687181 ]
    
    ixgbevf_init_module() won't destroy the workqueue created by
    create_singlethread_workqueue() when pci_register_driver() failed. Add
    destroy_workqueue() in fail path to prevent the resource leak.
    
    Similar to the handling of u132_hcd_init in commit f276e002793c
    ("usb: u132-hcd: fix resource leak")
    
    Fixes: 40a13e2493c9 ("ixgbevf: Use a private workqueue to avoid certain possible hangs")
    Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
    Reviewed-by: Saeed Mahameed <saeed@kernel.org>
    Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 35e0431d5f3a58c00aa1d83e8681c7e39d089aa3
Author: Shazad Hussain <quic_shazhuss@quicinc.com>
Date:   Tue Nov 15 20:59:56 2022 +0530

    clk: qcom: gcc-sc8280xp: add cxo as parent for three ufs ref clks
    
    [ Upstream commit f6abcc21d94393801937aed808b8f055ffec8579 ]
    
    The three UFS reference clocks, gcc_ufs_ref_clkref_clk for external
    UFS devices, gcc_ufs_card_clkref_clk and gcc_ufs_1_card_clkref_clk for
    two PHYs are all sourced from CXO.
    
    Added parent_data for all three reference clocks described above to
    reflect that all three clocks are sourced from CXO to have valid
    frequency for the ref clock needed by UFS controller driver.
    
    Fixes: d65d005f9a6c ("clk: qcom: add sc8280xp GCC driver")
    Link: https://lore.kernel.org/lkml/Y2Tber39cHuOSR%2FW@hovoldconsulting.com/
    Signed-off-by: Shazad Hussain <quic_shazhuss@quicinc.com>
    Tested-by: Johan Hovold <johan+linaro@kernel.org>
    Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
    Tested-by: Andrew Halaney <ahalaney@redhat.com>
    Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
    Reviewed-by: Brian Masney <bmasney@redhat.com>
    Link: https://lore.kernel.org/r/20221115152956.21677-1-quic_shazhuss@quicinc.com
    Reviewed-by: Bjorn Andersson <andersson@kernel.org>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ccc218d7659b3bded2dd5710c8995a4a06bc78cb
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Mon Nov 21 10:32:09 2022 +0800

    of: property: decrement node refcount in of_fwnode_get_reference_args()
    
    [ Upstream commit 60d865bd5a9b15a3961eb1c08bd4155682a3c81e ]
    
    In of_fwnode_get_reference_args(), the refcount of of_args.np has
    been incremented in the case of successful return from
    of_parse_phandle_with_args() or of_parse_phandle_with_fixed_args().
    
    Decrement the refcount if of_args is not returned to the caller of
    of_fwnode_get_reference_args().
    
    Fixes: 3e3119d3088f ("device property: Introduce fwnode_property_get_reference_args")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
    Reviewed-by: Frank Rowand <frowand.list@gmail.com>
    Link: https://lore.kernel.org/r/20221121023209.3909759-1-yangyingliang@huawei.com
    Signed-off-by: Rob Herring <robh@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2d7248efc2c54f68ada9d6325c392d7983912048
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Fri Nov 18 06:38:38 2022 +0000

    nvmem: rmem: Fix return value check in rmem_read()
    
    [ Upstream commit 58e92c4a496b27156020a59a98c7f4a92c2b1533 ]
    
    In case of error, the function memremap() returns NULL pointer
    not ERR_PTR(). The IS_ERR() test in the return value check
    should be replaced with NULL test.
    
    Fixes: 5a3fa75a4d9c ("nvmem: Add driver to expose reserved memory as nvmem")
    Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Cc: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Link: https://lore.kernel.org/r/20221118063840.6357-3-srinivas.kandagatla@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 091c52a67ba620a83bb3e1b52445791e49ede2d8
Author: Xu Kuohai <xukuohai@huawei.com>
Date:   Mon Nov 14 08:47:19 2022 -0500

    bpf: Do not copy spin lock field from user in bpf_selem_alloc
    
    [ Upstream commit 836e49e103dfeeff670c934b7d563cbd982fce87 ]
    
    bpf_selem_alloc function is used by inode_storage, sk_storage and
    task_storage maps to set map value, for these map types, there may
    be a spin lock in the map value, so if we use memcpy to copy the whole
    map value from user, the spin lock field may be initialized incorrectly.
    
    Since the spin lock field is zeroed by kzalloc, call copy_map_value
    instead of memcpy to skip copying the spin lock field to fix it.
    
    Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage")
    Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
    Link: https://lore.kernel.org/r/20221114134720.1057939-2-xukuohai@huawei.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 2eaf546bdb0d069737ddeca1a0e8c56c564340dd
Author: Joe Korty <joe.korty@concurrent-rt.com>
Date:   Mon Nov 21 14:53:43 2022 +0000

    clocksource/drivers/arm_arch_timer: Fix XGene-1 TVAL register math error
    
    [ Upstream commit 839a973988a94c15002cbd81536e4af6ced2bd30 ]
    
    The TVAL register is 32 bit signed.  Thus only the lower 31 bits are
    available to specify when an interrupt is to occur at some time in the
    near future.  Attempting to specify a larger interval with TVAL results
    in a negative time delta which means the timer fires immediately upon
    being programmed, rather than firing at that expected future time.
    
    The solution is for Linux to declare that TVAL is a 31 bit register rather
    than give its true size of 32 bits.  This prevents Linux from programming
    TVAL with a too-large value.  Note that, prior to 5.16, this little trick
    was the standard way to handle TVAL in Linux, so there is nothing new
    happening here on that front.
    
    The softlockup detector hides the issue, because it keeps generating
    short timer deadlines that are within the scope of the broken timer.
    
    Disabling it, it starts using NO_HZ with much longer timer deadlines, which
    turns into an interrupt flood:
    
     11: 1124855130  949168462  758009394   76417474  104782230   30210281
             310890 1734323687     GICv2  29 Level     arch_timer
    
    And "much longer" isn't that long: it takes less than 43s to underflow
    TVAL at 50MHz (the frequency of the counter on XGene-1).
    
    Some comments on the v1 version of this patch by Marc Zyngier:
    
      XGene implements CVAL (a 64bit comparator) in terms of TVAL (a countdown
      register) instead of the other way around. TVAL being a 32bit register,
      the width of the counter should equally be 32.  However, TVAL is a
      *signed* value, and keeps counting down in the negative range once the
      timer fires.
    
      It means that any TVAL value with bit 31 set will fire immediately,
      as it cannot be distinguished from an already expired timer. Reducing
      the timer range back to a paltry 31 bits papers over the issue.
    
      Another problem cannot be fixed though, which is that the timer interrupt
      *must* be handled within the negative countdown period, or the interrupt
      will be lost (TVAL will rollover to a positive value, indicative of a
      new timer deadline).
    
    Fixes: 012f18850452 ("clocksource/drivers/arm_arch_timer: Work around broken CVAL implementations")
    Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com>
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Marc Zyngier <maz@kernel.org>
    Link: https://lore.kernel.org/r/20221024165422.GA51107@zipoli.concurrent-rt.com
    Link: https://lore.kernel.org/r/20221121145343.896018-1-maz@kernel.org
    
    [maz: revamped the commit message]
    
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit e65cfd1f9cd27d9c27ee5cb88128a9f79f25d863
Author: Gaosheng Cui <cuigaosheng1@huawei.com>
Date:   Thu Nov 17 11:44:23 2022 +0800

    hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
    
    [ Upstream commit e2a87785aab0dac190ac89be6a9ba955e2c634f2 ]
    
    Smatch report warning as follows:
    
    drivers/hwmon/ibmpex.c:509 ibmpex_register_bmc() warn:
      '&data->list' not removed from list
    
    If ibmpex_find_sensors() fails in ibmpex_register_bmc(), data will
    be freed, but data->list will not be removed from driver_data.bmc_data,
    then list traversal may cause UAF.
    
    Fix by removeing it from driver_data.bmc_data before free().
    
    Fixes: 57c7c3a0fdea ("hwmon: IBM power meter driver")
    Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
    Link: https://lore.kernel.org/r/20221117034423.2935739-1-cuigaosheng1@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 30a65b0597b1f351e8652b6117a05c998189fdf0
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Sat Nov 12 20:56:06 2022 +0800

    hwmon: (i5500_temp) fix missing pci_disable_device()
    
    [ Upstream commit 3b7f98f237528c496ea0b689bace0e35eec3e060 ]
    
    pci_disable_device() need be called while module exiting, switch to use
    pcim_enable(), pci_disable_device() will be called in pcim_release().
    
    Fixes: ada072816be1 ("hwmon: (i5500_temp) New driver for the Intel 5500/5520/X58 chipsets")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221112125606.3751430-1-yangyingliang@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 53698b83026eec87e052ced8f9c77bee75f950f1
Author: Ninad Malwade <nmalwade@nvidia.com>
Date:   Tue Nov 8 12:45:08 2022 +0800

    hwmon: (ina3221) Fix shunt sum critical calculation
    
    [ Upstream commit b8d27d2ce8dfc207e4b67b929a86f2be76fbc6ef ]
    
    The shunt sum critical limit register value should be left shifted
    by one bit as its LSB-0 is a reserved bit.
    
    Fixes: 2057bdfb7184 ("hwmon: (ina3221) Add summation feature support")
    Signed-off-by: Ninad Malwade <nmalwade@nvidia.com>
    Reviewed-by: Thierry Reding <treding@nvidia.com>
    Link: https://lore.kernel.org/r/20221108044508.23463-1-nmalwade@nvidia.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b0c55416f6cfa77fe78aa527d85484cf76d895b6
Author: Derek Nguyen <derek.nguyen@collins.com>
Date:   Thu Nov 10 13:21:08 2022 -0600

    hwmon: (ltc2947) fix temperature scaling
    
    [ Upstream commit 07e06193ead86d4812f431b4d87bbd4161222e3f ]
    
    The LTC2947 datasheet (Rev. B) calls out in the section "Register
    Description: Non-Accumulated Result Registers" (pg. 30) that "To
    calculate temperature, multiply the TEMP register value by 0.204°C
    and add 5.5°C". Fix to add 5.5C and not 0.55C.
    
    Fixes: 9f90fd652bed ("hwmon: Add support for ltc2947")
    Signed-off-by: Derek Nguyen <derek.nguyen@collins.com>
    Signed-off-by: Brandon Maier <brandon.maier@collins.com>
    Link: https://lore.kernel.org/r/20221110192108.20624-1-brandon.maier@collins.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 535a25ab4f9a45f74ba38ab71de95e97474922ed
Author: Hou Tao <houtao1@huawei.com>
Date:   Wed Nov 16 15:23:49 2022 +0800

    libbpf: Handle size overflow for ringbuf mmap
    
    [ Upstream commit 927cbb478adf917e0a142b94baa37f06279cc466 ]
    
    The maximum size of ringbuf is 2GB on x86-64 host, so 2 * max_entries
    will overflow u32 when mapping producer page and data pages. Only
    casting max_entries to size_t is not enough, because for 32-bits
    application on 64-bits kernel the size of read-only mmap region
    also could overflow size_t.
    
    So fixing it by casting the size of read-only mmap region into a __u64
    and checking whether or not there will be overflow during mmap.
    
    Fixes: bf99c936f947 ("libbpf: Add BPF ring buffer support")
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20221116072351.1168938-3-houtao@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f70becfb659fa66b59fb8b9cd3fb71f1a687bcc4
Author: Michael Grzeschik <m.grzeschik@pengutronix.de>
Date:   Mon Nov 14 19:59:22 2022 +0100

    ARM: at91: rm9200: fix usb device clock id
    
    [ Upstream commit 57976762428675f259339385d3324d28ee53ec02 ]
    
    Referring to the datasheet the index 2 is the MCKUDP. When enabled, it
    "Enables the automatic disable of the Master Clock of the USB Device
    Port when a suspend condition occurs". We fix the index to the real UDP
    id which "Enables the 48 MHz clock of the USB Device Port".
    
    Cc: nicolas.ferre@microchip.com
    Cc: ludovic.desroches@microchip.com
    Cc: alexandre.belloni@bootlin.com
    Cc: mturquette@baylibre.com
    Cc: sboyd@kernel.org
    Cc: claudiu.beznea@microchip.com
    Cc: linux-clk@vger.kernel.org
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: kernel@pengutronix.de
    Fixes: 02ff48e4d7f7 ("clk: at91: add at91rm9200 pmc driver")
    Fixes: 0e0e528d8260 ("ARM: dts: at91: rm9200: switch to new clock bindings")
    Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
    Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20221114185923.1023249-2-m.grzeschik@pengutronix.de
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ace81d721c7a7414ff032eb8151494d5ae7e1aaa
Author: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Date:   Tue Sep 27 13:22:11 2022 +0530

    scripts/faddr2line: Fix regression in name resolution on ppc64le
    
    [ Upstream commit 2d77de1581bb5b470486edaf17a7d70151131afd ]
    
    Commit 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section
    failures") can cause faddr2line to fail on ppc64le on some
    distributions, while it works fine on other distributions. The failure
    can be attributed to differences in the readelf output.
    
      $ ./scripts/faddr2line vmlinux find_busiest_group+0x00
      no match for find_busiest_group+0x00
    
    On ppc64le, readelf adds the localentry tag before the symbol name on
    some distributions, and adds the localentry tag after the symbol name on
    other distributions. This problem has been discussed previously:
    
      https://lore.kernel.org/bpf/20191211160133.GB4580@calabresa/
    
    This problem can be overcome by filtering out the localentry tags in the
    readelf output. Similar fixes are already present in the kernel by way
    of the following commits:
    
      1fd6cee127e2 ("libbpf: Fix VERSIONED_SYM_COUNT number parsing")
      aa915931ac3e ("libbpf: Fix readelf output parsing for Fedora")
    
    [jpoimboe: rework commit log]
    
    Fixes: 1d1a0e7c5100 ("scripts/faddr2line: Fix overlapping text section failures")
    Signed-off-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
    Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Reviewed-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
    Link: https://lore.kernel.org/r/20220927075211.897152-1-srikar@linux.vnet.ibm.com
    Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
    Signed-off-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit ea263eb8ec0ee22893b072bafa078afd21c1fa4c
Author: Hou Tao <houtao1@huawei.com>
Date:   Mon Nov 14 17:57:33 2022 +0800

    bpf, perf: Use subprog name when reporting subprog ksymbol
    
    [ Upstream commit 47df8a2f78bc34ff170d147d05b121f84e252b85 ]
    
    Since commit bfea9a8574f3 ("bpf: Add name to struct bpf_ksym"), when
    reporting subprog ksymbol to perf, prog name instead of subprog name is
    used. The backtrace of bpf program with subprogs will be incorrect as
    shown below:
    
      ffffffffc02deace bpf_prog_e44a3057dcb151f8_overwrite+0x66
      ffffffffc02de9f7 bpf_prog_e44a3057dcb151f8_overwrite+0x9f
      ffffffffa71d8d4e trace_call_bpf+0xce
      ffffffffa71c2938 perf_call_bpf_enter.isra.0+0x48
    
    overwrite is the entry program and it invokes the overwrite_htab subprog
    through bpf_loop, but in above backtrace, overwrite program just jumps
    inside itself.
    
    Fixing it by using subprog name when reporting subprog ksymbol. After
    the fix, the output of perf script will be correct as shown below:
    
      ffffffffc031aad2 bpf_prog_37c0bec7d7c764a4_overwrite_htab+0x66
      ffffffffc031a9e7 bpf_prog_c7eb827ef4f23e71_overwrite+0x9f
      ffffffffa3dd8d4e trace_call_bpf+0xce
      ffffffffa3dc2938 perf_call_bpf_enter.isra.0+0x48
    
    Fixes: bfea9a8574f3 ("bpf: Add name to struct bpf_ksym")
    Signed-off-by: Hou Tao <houtao1@huawei.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Jiri Olsa <jolsa@kernel.org>
    Link: https://lore.kernel.org/bpf/20221114095733.158588-1-houtao@huaweicloud.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit edf4576a8196735aee23368df00482bf8321ddbf
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Mon Nov 14 15:52:57 2022 +0100

    libbpf: Use correct return pointer in attach_raw_tp
    
    [ Upstream commit 5fd2a60aecf3a42b14fa371c55b3dbb18b229230 ]
    
    We need to pass '*link' to final libbpf_get_error,
    because that one holds the return value, not 'link'.
    
    Fixes: 4fa5bcfe07f7 ("libbpf: Allow BPF program auto-attach handlers to bail out")
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20221114145257.882322-1-jolsa@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 73b49ac0d74a9de1c742c826c5a14602477b41c8
Author: Paul Gazzillo <paul@pgazz.com>
Date:   Thu Nov 10 16:47:29 2022 -0500

    iio: light: rpr0521: add missing Kconfig dependencies
    
    [ Upstream commit 6ac12303572ef9ace5603c2c07f5f1b00a33f580 ]
    
    Fix an implicit declaration of function error for rpr0521 under some configs
    
    When CONFIG_RPR0521 is enabled without CONFIG_IIO_TRIGGERED_BUFFER,
    the build results in "implicit declaration of function" errors, e.g.,
      drivers/iio/light/rpr0521.c:434:3: error: implicit declaration of function
               'iio_trigger_poll_chained' [-Werror=implicit-function-declaration]
        434 |   iio_trigger_poll_chained(data->drdy_trigger0);
            |   ^~~~~~~~~~~~~~~~~~~~~~~~
    
    This fix adds select dependencies to RPR0521's configuration declaration.
    
    Fixes: e12ffd241c00 ("iio: light: rpr0521 triggered buffer")
    Signed-off-by: Paul Gazzillo <paul@pgazz.com>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216678
    Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Link: https://lore.kernel.org/r/20221110214729.ls5ixav5kxpeftk7@device
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit d45d9f45e7b1365fd0d9bf14680d6d5082a590d1
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Mon Nov 7 15:20:10 2022 +0000

    iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw
    
    [ Upstream commit fc92d9e3de0b2d30a3ccc08048a5fad533e4672b ]
    
    KASAN report out-of-bounds read as follows:
    
    BUG: KASAN: global-out-of-bounds in afe4404_read_raw+0x2ce/0x380
    Read of size 4 at addr ffffffffc00e4658 by task cat/278
    
    Call Trace:
     afe4404_read_raw
     iio_read_channel_info
     dev_attr_show
    
    The buggy address belongs to the variable:
     afe4404_channel_leds+0x18/0xffffffffffffe9c0
    
    This issue can be reproduce by singe command:
    
     $ cat /sys/bus/i2c/devices/0-0058/iio\:device0/in_intensity6_raw
    
    The array size of afe4404_channel_leds and afe4404_channel_offdacs
    are less than channels, so access with chan->address cause OOB read
    in afe4404_[read|write]_raw. Fix it by moving access before use them.
    
    Fixes: b36e8257641a ("iio: health/afe440x: Use regmap fields")
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Acked-by: Andrew Davis <afd@ti.com>
    Link: https://lore.kernel.org/r/20221107152010.95937-1-weiyongjun@huaweicloud.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 06c6ce21cec77dfa860d57e7a006000a57812efb
Author: Wei Yongjun <weiyongjun1@huawei.com>
Date:   Mon Nov 7 15:19:46 2022 +0000

    iio: health: afe4403: Fix oob read in afe4403_read_raw
    
    [ Upstream commit 58143c1ed5882c138a3cd2251a336fc8755f23d9 ]
    
    KASAN report out-of-bounds read as follows:
    
    BUG: KASAN: global-out-of-bounds in afe4403_read_raw+0x42e/0x4c0
    Read of size 4 at addr ffffffffc02ac638 by task cat/279
    
    Call Trace:
     afe4403_read_raw
     iio_read_channel_info
     dev_attr_show
    
    The buggy address belongs to the variable:
     afe4403_channel_leds+0x18/0xffffffffffffe9e0
    
    This issue can be reproduced by singe command:
    
     $ cat /sys/bus/spi/devices/spi0.0/iio\:device0/in_intensity6_raw
    
    The array size of afe4403_channel_leds is less than channels, so access
    with chan->address cause OOB read in afe4403_read_raw. Fix it by moving
    access before use it.
    
    Fixes: b36e8257641a ("iio: health/afe440x: Use regmap fields")
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
    Acked-by: Andrew Davis <afd@ti.com>
    Link: https://lore.kernel.org/r/20221107151946.89260-1-weiyongjun@huaweicloud.com
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 56929ca9a99644f692b10f2b327624350ea5b7c5
Author: Stephen Boyd <swboyd@chromium.org>
Date:   Thu Nov 3 11:30:30 2022 -0700

    clk: qcom: gdsc: Remove direct runtime PM calls
    
    [ Upstream commit 4cc47e8add635408e063c98b52d56b7ceacf0b70 ]
    
    We shouldn't be calling runtime PM APIs from within the genpd
    enable/disable path for a couple reasons.
    
    First, this causes an AA lockdep splat[1] because genpd can call into
    genpd code again while holding the genpd lock.
    
    WARNING: possible recursive locking detected
    5.19.0-rc2-lockdep+ #7 Not tainted
    --------------------------------------------
    kworker/2:1/49 is trying to acquire lock:
    ffffffeea0370788 (&genpd->mlock){+.+.}-{3:3}, at: genpd_lock_mtx+0x24/0x30
    
    but task is already holding lock:
    ffffffeea03710a8 (&genpd->mlock){+.+.}-{3:3}, at: genpd_lock_mtx+0x24/0x30
    
    other info that might help us debug this:
     Possible unsafe locking scenario:
    
           CPU0
           ----
      lock(&genpd->mlock);
      lock(&genpd->mlock);
    
     *** DEADLOCK ***
    
     May be due to missing lock nesting notation
    
    3 locks held by kworker/2:1/49:
     #0: 74ffff80811a5748 ((wq_completion)pm){+.+.}-{0:0}, at: process_one_work+0x320/0x5fc
     #1: ffffffc008537cf8 ((work_completion)(&genpd->power_off_work)){+.+.}-{0:0}, at: process_one_work+0x354/0x5fc
     #2: ffffffeea03710a8 (&genpd->mlock){+.+.}-{3:3}, at: genpd_lock_mtx+0x24/0x30
    
    stack backtrace:
    CPU: 2 PID: 49 Comm: kworker/2:1 Not tainted 5.19.0-rc2-lockdep+ #7
    Hardware name: Google Lazor (rev3 - 8) with KB Backlight (DT)
    Workqueue: pm genpd_power_off_work_fn
    Call trace:
     dump_backtrace+0x1a0/0x200
     show_stack+0x24/0x30
     dump_stack_lvl+0x7c/0xa0
     dump_stack+0x18/0x44
     __lock_acquire+0xb38/0x3634
     lock_acquire+0x180/0x2d4
     __mutex_lock_common+0x118/0xe30
     mutex_lock_nested+0x70/0x7c
     genpd_lock_mtx+0x24/0x30
     genpd_runtime_suspend+0x2f0/0x414
     __rpm_callback+0xdc/0x1b8
     rpm_callback+0x4c/0xcc
     rpm_suspend+0x21c/0x5f0
     rpm_idle+0x17c/0x1e0
     __pm_runtime_idle+0x78/0xcc
     gdsc_disable+0x24c/0x26c
     _genpd_power_off+0xd4/0x1c4
     genpd_power_off+0x2d8/0x41c
     genpd_power_off_work_fn+0x60/0x94
     process_one_work+0x398/0x5fc
     worker_thread+0x42c/0x6c4
     kthread+0x194/0x1b4
     ret_from_fork+0x10/0x20
    
    Second, this confuses runtime PM on CoachZ for the camera devices by
    causing the camera clock controller's runtime PM usage_count to go
    negative after resuming from suspend. This is because runtime PM is
    being used on the clock controller while runtime PM is disabled for the
    device.
    
    The reason for the negative count is because a GDSC is represented as a
    genpd and each genpd that is attached to a device is resumed during the
    noirq phase of system wide suspend/resume (see the noirq suspend ops
    assignment in pm_genpd_init() for more details). The camera GDSCs are
    attached to camera devices with the 'power-domains' property in DT.
    Every device has runtime PM disabled in the late system suspend phase
    via __device_suspend_late(). Runtime PM is not usable until runtime PM
    is enabled in device_resume_early(). The noirq phases run after the
    'late' and before the 'early' phase of suspend/resume. When the genpds
    are resumed in genpd_resume_noirq(), we call down into gdsc_enable()
    that calls pm_runtime_resume_and_get() and that returns -EACCES to
    indicate failure to resume because runtime PM is disabled for all
    devices.
    
    Upon closer inspection, calling runtime PM APIs like this in the GDSC
    driver doesn't make sense. It was intended to make sure the GDSC for the
    clock controller providing other GDSCs was enabled, specifically the
    MMCX GDSC for the display clk controller on SM8250 (sm8250-dispcc), so
    that GDSC register accesses succeeded. That will already happen because
    we make the 'dev->pm_domain' a parent domain of each GDSC we register in
    gdsc_register() via pm_genpd_add_subdomain(). When any of these GDSCs
    are accessed, we'll enable the parent domain (in this specific case
    MMCX).
    
    We also remove any getting of runtime PM during registration, because
    when a genpd is registered it increments the count on the parent if the
    genpd itself is already enabled.
    
    Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Cc: Johan Hovold <johan+linaro@kernel.org>
    Cc: Ulf Hansson <ulf.hansson@linaro.org>
    Cc: Taniya Das <quic_tdas@quicinc.com>
    Cc: Satya Priya <quic_c_skakit@quicinc.com>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Tested-by: Douglas Anderson <dianders@chromium.org>
    Cc: Matthias Kaehlcke <mka@chromium.org>
    Reported-by: Stephen Boyd <swboyd@chromium.org>
    Link: https://lore.kernel.org/r/CAE-0n52xbZeJ66RaKwggeRB57fUAwjvxGxfFMKOKJMKVyFTe+w@mail.gmail.com [1]
    Fixes: 1b771839de05 ("clk: qcom: gdsc: enable optional power domain support")
    Signed-off-by: Stephen Boyd <swboyd@chromium.org>
    Link: https://lore.kernel.org/r/20221103183030.3594899-1-swboyd@chromium.org
    Tested-by: Johan Hovold <johan+linaro@kernel.org>
    Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c91f91208eb0d2c4534b5ee5d0e57a82f0a356d7
Author: Johan Hovold <johan+linaro@kernel.org>
Date:   Thu Sep 29 17:58:16 2022 +0200

    clk: qcom: gdsc: add missing error handling
    
    [ Upstream commit eab4c1ebdd657957bf7ae66ffb8849b462db78b3 ]
    
    Since commit 7eb231c337e0 ("PM / Domains: Convert pm_genpd_init() to
    return an error code") pm_genpd_init() can return an error which the
    caller must handle.
    
    The current error handling was also incomplete as the runtime PM and
    regulator use counts were not balanced in all error paths.
    
    Add the missing error handling to the GDSC initialisation to avoid
    continuing as if nothing happened on errors.
    
    Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
    Signed-off-by: Bjorn Andersson <andersson@kernel.org>
    Link: https://lore.kernel.org/r/20220929155816.17425-1-johan+linaro@kernel.org
    Stable-dep-of: 4cc47e8add63 ("clk: qcom: gdsc: Remove direct runtime PM calls")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b81f5ac248cf6d5dcf6926213a7e9e4a0cbc197f
Author: David Virag <virag.david003@gmail.com>
Date:   Thu Oct 13 17:13:40 2022 +0200

    clk: samsung: exynos7885: Correct "div4" clock parents
    
    [ Upstream commit ef80c95c29dc67c3034f32d93c41e2ede398e387 ]
    
    "div4" DIVs which divide PLLs by 4 are actually dividing "div2" DIVs by
    2 to achieve a by 4 division, thus their parents are the respective
    "div2" DIVs. These DIVs were mistakenly set to have the PLLs as parents.
    This leads to the kernel thinking "div4"s and everything under them run
    at 2x the clock speed. Fix this.
    
    Fixes: 45bd8166a1d8 ("clk: samsung: Add initial Exynos7885 clock driver")
    Signed-off-by: David Virag <virag.david003@gmail.com>
    Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
    Link: https://lore.kernel.org/r/20221013151341.151208-1-virag.david003@gmail.com
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit b1b44e34a8549794df8cac07573dcec57fa53c8a
Author: lyndonli <Lyndon.Li@amd.com>
Date:   Mon Nov 21 09:08:42 2022 +0800

    drm/amd/pm: update driver if header for smu_13_0_7
    
    [ Upstream commit f2e1aa267f12b82e03927d1e918d2844ddd3eea5 ]
    
    update driver if header for smu_13_0_7
    
    Signed-off-by: lyndonli <Lyndon.Li@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
    Reviewed-by: Evan Quan <evan.quan@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org # 6.0.x
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit bab87ec65793bbd2697f4412753631065d8a9144
Author: Kenneth Feng <kenneth.feng@amd.com>
Date:   Wed Oct 19 11:24:05 2022 +0800

    drm/amd/pm: update driver-if header for smu_v13_0_10
    
    [ Upstream commit 09aef0258a327409bb2279a5ba8f82ad2ca099ca ]
    
    update driver-if header for smu_v13_0_10 and merge with smu_v13_0_0
    
    Signed-off-by: Kenneth Feng <kenneth.feng@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Stable-dep-of: f2e1aa267f12 ("drm/amd/pm: update driver if header for smu_13_0_7")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit a3ad937f5fd0d41874f888d38afba1d74121701a
Author: Yang Wang <KevinYang.Wang@amd.com>
Date:   Fri Mar 18 20:05:32 2022 +0800

    drm/amd/pm: add smu_v13_0_10 driver if version
    
    [ Upstream commit 8e039cd176c61a9770e1956038c93738efc800f7 ]
    
    add smu_v13_0_10 driver if version
    
    Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
    Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Stable-dep-of: f2e1aa267f12 ("drm/amd/pm: update driver if header for smu_13_0_7")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit f19d86da901c218d622225e458e289bcf0aacbfc
Author: Christian König <christian.koenig@amd.com>
Date:   Thu Nov 10 12:31:41 2022 +0100

    drm/amdgpu: fix userptr HMM range handling v2
    
    [ Upstream commit 4458da0bb09d4435956b4377685e8836935e9b9d ]
    
    The basic problem here is that it's not allowed to page fault while
    holding the reservation lock.
    
    So it can happen that multiple processes try to validate an userptr
    at the same time.
    
    Work around that by putting the HMM range object into the mutex
    protected bo list for now.
    
    v2: make sure range is set to NULL in case of an error
    
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
    CC: stable@vger.kernel.org
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 0ec9cd561f25671fc3df29d41c23fb2780dc0812
Author: Christian König <christian.koenig@amd.com>
Date:   Tue Sep 13 09:52:13 2022 +0200

    drm/amdgpu: cleanup error handling in amdgpu_cs_parser_bos
    
    [ Upstream commit 4953b6b22ab9d7f64706631a027b1ed1130ce4c8 ]
    
    Return early on success and so remove all those "if (r)" in the error
    path.
    
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Stable-dep-of: 4458da0bb09d ("drm/amdgpu: fix userptr HMM range handling v2")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit c820764e1da0545c9e1f465947c450fdb26a1432
Author: Christian König <christian.koenig@amd.com>
Date:   Tue Mar 1 10:59:14 2022 +0100

    drm/amdgpu: move setting the job resources
    
    [ Upstream commit 736ec9fadd7a1fde8480df7e5cfac465c07ff6f3 ]
    
    Move setting the job resources into amdgpu_job.c
    
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
    Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Stable-dep-of: 4458da0bb09d ("drm/amdgpu: fix userptr HMM range handling v2")
    Signed-off-by: Sasha Levin <sashal@kernel.org>

commit 588ae4fdd8b11788a797776b10d6c44ae12bc133
Author: ChenXiaoSong <chenxiaosong2@huawei.com>
Date:   Wed Nov 16 22:23:54 2022 +0800

    btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit()
    
    [ Upstream commit f7e942b5bb35d8e3af54053d19a6bf04143a3955 ]
    
    Syzkaller reported BUG as follows:
    
      BUG: sleeping function called from invalid context at
           include/linux/sched/mm.h:274
      Call Trace:
       <TASK>
       dump_stack_lvl+0xcd/0x134
       __might_resched.cold+0x222/0x26b
       kmem_cache_alloc+0x2e7/0x3c0
       update_qgroup_limit_item+0xe1/0x390
       btrfs_qgroup_inherit+0x147b/0x1ee0
       create_subvol+0x4eb/0x1710
       btrfs_mksubvol+0xfe5/0x13f0
       __btrfs_ioctl_snap_create+0x2b0/0x430
       btrfs_ioctl_snap_create_v2+0x25a/0x520
       btrfs_ioctl+0x2a1c/0x5ce0
       __x64_sys_ioctl+0x193/0x200
       do_syscall_64+0x35/0x80
    
    Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in
    btrfs_run_qgroups() later outside of the spinlock context.
    
    CC: stable@vger.kernel.org # 4.9+
    Reviewed-by: Qu Wenruo <wqu@suse.com>
    Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>