Skip to content
  1. May 17, 2024
    • Lakshmi Yadlapati's avatar
      hwmon: (pmbus/ucd9000) Increase delay from 250 to 500us · a2740fe9
      Lakshmi Yadlapati authored
      commit 26e8383b
      
       upstream.
      
      Following the failure observed with a delay of 250us, experiments were
      conducted with various delays. It was found that a delay of 350us
      effectively mitigated the issue.
      
      To provide a more optimal solution while still allowing a margin for
      stability, the delay is being adjusted to 500us.
      
      Signed-off-by: default avatarLakshmi Yadlapati <lakshmiy@us.ibm.com>
      Link: https://lore.kernel.org/r/20240507194603.1305750-1-lakshmiy@us.ibm.com
      Fixes: 8d655e65
      
       ("hwmon: (ucd90320) Add minimum delay between bus accesses")
      Reviewed-by: default avatarEddie James <eajames@linux.ibm.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2740fe9
    • Thadeu Lima de Souza Cascardo's avatar
      net: fix out-of-bounds access in ops_init · 2d60ff58
      Thadeu Lima de Souza Cascardo authored
      commit a26ff37e
      
       upstream.
      
      net_alloc_generic is called by net_alloc, which is called without any
      locking. It reads max_gen_ptrs, which is changed under pernet_ops_rwsem. It
      is read twice, first to allocate an array, then to set s.len, which is
      later used to limit the bounds of the array access.
      
      It is possible that the array is allocated and another thread is
      registering a new pernet ops, increments max_gen_ptrs, which is then used
      to set s.len with a larger than allocated length for the variable array.
      
      Fix it by reading max_gen_ptrs only once in net_alloc_generic. If
      max_gen_ptrs is later incremented, it will be caught in net_assign_generic.
      
      Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@igalia.com>
      Fixes: 073862ba
      
       ("netns: fix net_alloc_generic()")
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20240502132006.3430840-1-cascardo@igalia.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d60ff58
    • George Shen's avatar
      drm/amd/display: Handle Y carry-over in VCP X.Y calculation · ce740545
      George Shen authored
      commit 71956473
      
       upstream.
      
      Theoretically rare corner case where ceil(Y) results in rounding up to
      an integer. If this happens, the 1 should be carried over to the X
      value.
      
      CC: stable@vger.kernel.org
      Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarGeorge Shen <george.shen@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce740545
    • Karthikeyan Ramasubramanian's avatar
      drm/i915/bios: Fix parsing backlight BDB data · d8cdbd0f
      Karthikeyan Ramasubramanian authored
      commit 43b26bdd upstream.
      
      Starting BDB version 239, hdr_dpcd_refresh_timeout is introduced to
      backlight BDB data. Commit 70003456 ("drm/i915/bios: Define more BDB
      contents") updated the backlight BDB data accordingly. This broke the
      parsing of backlight BDB data in VBT for versions 236 - 238 (both
      inclusive) and hence the backlight controls are not responding on units
      with the concerned BDB version.
      
      backlight_control information has been present in backlight BDB data
      from at least BDB version 191 onwards, if not before. Hence this patch
      extracts the backlight_control information for BDB version 191 or newer.
      Tested on Chromebooks using Jasperlake SoC (reports bdb->version = 236).
      Tested on Chromebooks using Raptorlake SoC (reports bdb->version = 251).
      
      v2: removed checking the block size of the backlight BDB data
          [vsyrjala: this is completely safe thanks to commit e163cfb4
           ("drm/i915/bios: Make copies of VBT data blocks")]
      
      Fixes: 70003456
      
       ("drm/i915/bios: Define more BDB contents")
      Cc: stable@vger.kernel.org
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarKarthikeyan Ramasubramanian <kramasub@chromium.org>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240221180622.v2.1.I0690aa3e96a83a43b3fc33f50395d334b2981826@changeid
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      (cherry picked from commit c286f6a9
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8cdbd0f
    • Zack Rusin's avatar
      drm/vmwgfx: Fix invalid reads in fence signaled events · 0dbfc736
      Zack Rusin authored
      commit a37ef761
      
       upstream.
      
      Correctly set the length of the drm_event to the size of the structure
      that's actually used.
      
      The length of the drm_event was set to the parent structure instead of
      to the drm_vmw_event_fence which is supposed to be read. drm_read
      uses the length parameter to copy the event to the user space thus
      resuling in oob reads.
      
      Signed-off-by: default avatarZack Rusin <zack.rusin@broadcom.com>
      Fixes: 8b7de6aa
      
       ("vmwgfx: Rework fence event action")
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-23566
      Cc: David Airlie <airlied@gmail.com>
      CC: Daniel Vetter <daniel@ffwll.ch>
      Cc: Zack Rusin <zack.rusin@broadcom.com>
      Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
      Cc: dri-devel@lists.freedesktop.org
      Cc: linux-kernel@vger.kernel.org
      Cc: <stable@vger.kernel.org> # v3.4+
      Reviewed-by: default avatarMaaz Mombasawala <maaz.mombasawala@broadcom.com>
      Reviewed-by: default avatarMartin Krastev <martin.krastev@broadcom.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240425192748.1761522-1-zack.rusin@broadcom.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0dbfc736
    • Alex Deucher's avatar
      drm/amdkfd: don't allow mapping the MMIO HDP page with large pages · 89fffbdf
      Alex Deucher authored
      commit be4a2a81 upstream.
      
      We don't get the right offset in that case.  The GPU has
      an unused 4K area of the register BAR space into which you can
      remap registers.  We remap the HDP flush registers into this
      space to allow userspace (CPU or GPU) to flush the HDP when it
      updates VRAM.  However, on systems with >4K pages, we end up
      exposing PAGE_SIZE of MMIO space.
      
      Fixes: d8e408a8
      
       ("drm/amdkfd: Expose HDP registers to user space")
      Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89fffbdf
    • Alexander Usyskin's avatar
      mei: me: add lunar lake point M DID · c42a8c6b
      Alexander Usyskin authored
      commit 4108a30f
      
       upstream.
      
      Add Lunar (Point) Lake M device id.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
      Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Link: https://lore.kernel.org/r/20240421135631.223362-1-tomas.winkler@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c42a8c6b
    • Viken Dadhaniya's avatar
      slimbus: qcom-ngd-ctrl: Add timeout for wait operation · eedaabee
      Viken Dadhaniya authored
      commit 98241a77 upstream.
      
      In current driver qcom_slim_ngd_up_worker() indefinitely
      waiting for ctrl->qmi_up completion object. This is
      resulting in workqueue lockup on Kthread.
      
      Added wait_for_completion_interruptible_timeout to
      allow the thread to wait for specific timeout period and
      bail out instead waiting infinitely.
      
      Fixes: a899d324
      
       ("slimbus: qcom-ngd-ctrl: add Sub System Restart support")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Signed-off-by: default avatarViken Dadhaniya <quic_vdadhani@quicinc.com>
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20240430091238.35209-2-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eedaabee
    • Jim Cromie's avatar
      dyndbg: fix old BUG_ON in >control parser · a66c869b
      Jim Cromie authored
      commit 00e7d3be
      
       upstream.
      
      Fix a BUG_ON from 2009.  Even if it looks "unreachable" (I didn't
      really look), lets make sure by removing it, doing pr_err and return
      -EINVAL instead.
      
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Link: https://lore.kernel.org/r/20240429193145.66543-2-jim.cromie@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a66c869b
    • Joao Paulo Goncalves's avatar
      ASoC: ti: davinci-mcasp: Fix race condition during probe · 0b47bbc9
      Joao Paulo Goncalves authored
      commit d18ca863 upstream.
      
      When using davinci-mcasp as CPU DAI with simple-card, there are some
      conditions that cause simple-card to finish registering a sound card before
      davinci-mcasp finishes registering all sound components. This creates a
      non-working sound card from userspace with no problem indication apart
      from not being able to play/record audio on a PCM stream. The issue
      arises during simultaneous probe execution of both drivers. Specifically,
      the simple-card driver, awaiting a CPU DAI, proceeds as soon as
      davinci-mcasp registers its DAI. However, this process can lead to the
      client mutex lock (client_mutex in soc-core.c) being held or davinci-mcasp
      being preempted before PCM DMA registration on davinci-mcasp finishes.
      This situation occurs when the probes of both drivers run concurrently.
      Below is the code path for this condition. To solve the issue, defer
      davinci-mcasp CPU DAI registration to the last step in the audio part of
      it. This way, simple-card CPU DAI parsing will be deferred until all
      audio components are registered.
      
      Fail Code Path:
      
      simple-card.c: probe starts
      simple-card.c: simple_dai_link_of: simple_parse_node(..,cpu,..) returns EPROBE_DEFER, no CPU DAI yet
      davinci-mcasp.c: probe starts
      davinci-mcasp.c: devm_snd_soc_register_component() register CPU DAI
      simple-card.c: probes again, finish CPU DAI parsing and call devm_snd_soc_register_card()
      simple-card.c: finish probe
      davinci-mcasp.c: *dma_pcm_platform_register() register PCM  DMA
      davinci-mcasp.c: probe finish
      
      Cc: stable@vger.kernel.org
      Fixes: 9fbd58cf
      
       ("ASoC: davinci-mcasp: Choose PCM driver based on configured DMA controller")
      Signed-off-by: default avatarJoao Paulo Goncalves <joao.goncalves@toradex.com>
      Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@gmail.com>
      Reviewed-by: default avatarJai Luthra <j-luthra@ti.com>
      Link: https://lore.kernel.org/r/20240417184138.1104774-1-jpaulo.silvagoncalves@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b47bbc9
    • Sameer Pujar's avatar
      ASoC: tegra: Fix DSPK 16-bit playback · 9c301fd3
      Sameer Pujar authored
      commit 2e93a29b upstream.
      
      DSPK configuration is wrong for 16-bit playback and this happens because
      the client config is always fixed at 24-bit in hw_params(). Fix this by
      updating the client config to 16-bit for the respective playback.
      
      Fixes: 327ef647
      
       ("ASoC: tegra: Add Tegra186 based DSPK driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSameer Pujar <spujar@nvidia.com>
      Acked-by: default avatarThierry Reding <treding@nvidia.com>
      Link: https://msgid.link/r/20240405104306.551036-1-spujar@nvidia.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c301fd3
    • Paolo Abeni's avatar
      tipc: fix UAF in error path · 21ea04aa
      Paolo Abeni authored
      commit 080cbb89 upstream.
      
      Sam Page (sam4k) working with Trend Micro Zero Day Initiative reported
      a UAF in the tipc_buf_append() error path:
      
      BUG: KASAN: slab-use-after-free in kfree_skb_list_reason+0x47e/0x4c0
      linux/net/core/skbuff.c:1183
      Read of size 8 at addr ffff88804d2a7c80 by task poc/8034
      
      CPU: 1 PID: 8034 Comm: poc Not tainted 6.8.2 #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.16.0-debian-1.16.0-5 04/01/2014
      Call Trace:
       <IRQ>
       __dump_stack linux/lib/dump_stack.c:88
       dump_stack_lvl+0xd9/0x1b0 linux/lib/dump_stack.c:106
       print_address_description linux/mm/kasan/report.c:377
       print_report+0xc4/0x620 linux/mm/kasan/report.c:488
       kasan_report+0xda/0x110 linux/mm/kasan/report.c:601
       kfree_skb_list_reason+0x47e/0x4c0 linux/net/core/skbuff.c:1183
       skb_release_data+0x5af/0x880 linux/net/core/skbuff.c:1026
       skb_release_all linux/net/core/skbuff.c:1094
       __kfree_skb linux/net/core/skbuff.c:1108
       kfree_skb_reason+0x12d/0x210 linux/net/core/skbuff.c:1144
       kfree_skb linux/./include/linux/skbuff.h:1244
       tipc_buf_append+0x425/0xb50 linux/net/tipc/msg.c:186
       tipc_link_input+0x224/0x7c0 linux/net/tipc/link.c:1324
       tipc_link_rcv+0x76e/0x2d70 linux/net/tipc/link.c:1824
       tipc_rcv+0x45f/0x10f0 linux/net/tipc/node.c:2159
       tipc_udp_recv+0x73b/0x8f0 linux/net/tipc/udp_media.c:390
       udp_queue_rcv_one_skb+0xad2/0x1850 linux/net/ipv4/udp.c:2108
       udp_queue_rcv_skb+0x131/0xb00 linux/net/ipv4/udp.c:2186
       udp_unicast_rcv_skb+0x165/0x3b0 linux/net/ipv4/udp.c:2346
       __udp4_lib_rcv+0x2594/0x3400 linux/net/ipv4/udp.c:2422
       ip_protocol_deliver_rcu+0x30c/0x4e0 linux/net/ipv4/ip_input.c:205
       ip_local_deliver_finish+0x2e4/0x520 linux/net/ipv4/ip_input.c:233
       NF_HOOK linux/./include/linux/netfilter.h:314
       NF_HOOK linux/./include/linux/netfilter.h:308
       ip_local_deliver+0x18e/0x1f0 linux/net/ipv4/ip_input.c:254
       dst_input linux/./include/net/dst.h:461
       ip_rcv_finish linux/net/ipv4/ip_input.c:449
       NF_HOOK linux/./include/linux/netfilter.h:314
       NF_HOOK linux/./include/linux/netfilter.h:308
       ip_rcv+0x2c5/0x5d0 linux/net/ipv4/ip_input.c:569
       __netif_receive_skb_one_core+0x199/0x1e0 linux/net/core/dev.c:5534
       __netif_receive_skb+0x1f/0x1c0 linux/net/core/dev.c:5648
       process_backlog+0x101/0x6b0 linux/net/core/dev.c:5976
       __napi_poll.constprop.0+0xba/0x550 linux/net/core/dev.c:6576
       napi_poll linux/net/core/dev.c:6645
       net_rx_action+0x95a/0xe90 linux/net/core/dev.c:6781
       __do_softirq+0x21f/0x8e7 linux/kernel/softirq.c:553
       do_softirq linux/kernel/softirq.c:454
       do_softirq+0xb2/0xf0 linux/kernel/softirq.c:441
       </IRQ>
       <TASK>
       __local_bh_enable_ip+0x100/0x120 linux/kernel/softirq.c:381
       local_bh_enable linux/./include/linux/bottom_half.h:33
       rcu_read_unlock_bh linux/./include/linux/rcupdate.h:851
       __dev_queue_xmit+0x871/0x3ee0 linux/net/core/dev.c:4378
       dev_queue_xmit linux/./include/linux/netdevice.h:3169
       neigh_hh_output linux/./include/net/neighbour.h:526
       neigh_output linux/./include/net/neighbour.h:540
       ip_finish_output2+0x169f/0x2550 linux/net/ipv4/ip_output.c:235
       __ip_finish_output linux/net/ipv4/ip_output.c:313
       __ip_finish_output+0x49e/0x950 linux/net/ipv4/ip_output.c:295
       ip_finish_output+0x31/0x310 linux/net/ipv4/ip_output.c:323
       NF_HOOK_COND linux/./include/linux/netfilter.h:303
       ip_output+0x13b/0x2a0 linux/net/ipv4/ip_output.c:433
       dst_output linux/./include/net/dst.h:451
       ip_local_out linux/net/ipv4/ip_output.c:129
       ip_send_skb+0x3e5/0x560 linux/net/ipv4/ip_output.c:1492
       udp_send_skb+0x73f/0x1530 linux/net/ipv4/udp.c:963
       udp_sendmsg+0x1a36/0x2b40 linux/net/ipv4/udp.c:1250
       inet_sendmsg+0x105/0x140 linux/net/ipv4/af_inet.c:850
       sock_sendmsg_nosec linux/net/socket.c:730
       __sock_sendmsg linux/net/socket.c:745
       __sys_sendto+0x42c/0x4e0 linux/net/socket.c:2191
       __do_sys_sendto linux/net/socket.c:2203
       __se_sys_sendto linux/net/socket.c:2199
       __x64_sys_sendto+0xe0/0x1c0 linux/net/socket.c:2199
       do_syscall_x64 linux/arch/x86/entry/common.c:52
       do_syscall_64+0xd8/0x270 linux/arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x6f/0x77 linux/arch/x86/entry/entry_64.S:120
      RIP: 0033:0x7f3434974f29
      Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48
      89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d
      01 f0 ff ff 73 01 c3 48 8b 0d 37 8f 0d 00 f7 d8 64 89 01 48
      RSP: 002b:00007fff9154f2b8 EFLAGS: 00000212 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3434974f29
      RDX: 00000000000032c8 RSI: 00007fff9154f300 RDI: 0000000000000003
      RBP: 00007fff915532e0 R08: 00007fff91553360 R09: 0000000000000010
      R10: 0000000000000000 R11: 0000000000000212 R12: 000055ed86d261d0
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      In the critical scenario, either the relevant skb is freed or its
      ownership is transferred into a frag_lists. In both cases, the cleanup
      code must not free it again: we need to clear the skb reference earlier.
      
      Fixes: 1149557d
      
       ("tipc: eliminate unnecessary linearization of incoming buffers")
      Cc: stable@vger.kernel.org
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-23852
      Acked-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Link: https://lore.kernel.org/r/752f1ccf762223d109845365d07f55414058e5a3.1714484273.git.pabeni@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21ea04aa
    • Alexander Potapenko's avatar
      kmsan: compiler_types: declare __no_sanitize_or_inline · 50a436d0
      Alexander Potapenko authored
      commit 90d1f14c upstream.
      
      It turned out that KMSAN instruments READ_ONCE_NOCHECK(), resulting in
      false positive reports, because __no_sanitize_or_inline enforced inlining.
      
      Properly declare __no_sanitize_or_inline under __SANITIZE_MEMORY__, so
      that it does not __always_inline the annotated function.
      
      Link: https://lkml.kernel.org/r/20240426091622.3846771-1-glider@google.com
      Fixes: 5de0ce85
      
       ("kmsan: mark noinstr as __no_sanitize_memory")
      Signed-off-by: default avatarAlexander Potapenko <glider@google.com>
      Reported-by: default avatar <syzbot+355c5bb8c1445c871ee8@syzkaller.appspotmail.com>
      Link: https://lkml.kernel.org/r/000000000000826ac1061675b0e3@google.com
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarMarco Elver <elver@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50a436d0
    • Hans de Goede's avatar
      iio: accel: mxc4005: Interrupt handling fixes · b56d4991
      Hans de Goede authored
      commit 57a15927 upstream.
      
      There are 2 issues with interrupt handling in the mxc4005 driver:
      
      1. mxc4005_set_trigger_state() writes MXC4005_REG_INT_MASK1_BIT_DRDYE
      (0x01) to INT_MASK1 to enable the interrupt, but to disable the interrupt
      it writes ~MXC4005_REG_INT_MASK1_BIT_DRDYE which is 0xfe, so it enables
      all other interrupt sources in the INT_SRC1 register. On the MXC4005 this
      is not an issue because only bit 0 of the register is used. On the MXC6655
      OTOH this is a problem since bit7 is used as TC (Temperature Compensation)
      disable bit and writing 1 to this disables Temperature Compensation which
      should only be done when running self-tests on the chip.
      
      Write 0 instead of ~MXC4005_REG_INT_MASK1_BIT_DRDYE to disable
      the interrupts to fix this.
      
      2. The datasheets for the MXC4005 / MXC6655 do not state what the reset
      value for the INT_MASK0 and INT_MASK1 registers is and since these are
      write only we also cannot learn this from the hw. Presumably the reset
      value for both is all 0, which means all interrupts disabled.
      
      Explicitly set both registers to 0 from mxc4005_chip_init() to ensure
      both masks are actually set to 0.
      
      Fixes: 79846e33
      
       ("iio: accel: mxc4005: add support for mxc6655")
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20240326113700.56725-2-hdegoede@redhat.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b56d4991
    • Ramona Gradinariu's avatar
      iio:imu: adis16475: Fix sync mode setting · 50fa09df
      Ramona Gradinariu authored
      commit 74a72baf upstream.
      
      Fix sync mode setting by applying the necessary shift bits.
      
      Fixes: fff7352b
      
       ("iio: imu: Add support for adis16475")
      Signed-off-by: default avatarRamona Gradinariu <ramona.bolboaca13@gmail.com>
      Reviewed-by: default avatarNuno Sa <nuno.sa@analog.com>
      Link: https://lore.kernel.org/r/20240405045309.816328-2-ramona.bolboaca13@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50fa09df
    • Javier Carrasco's avatar
      dt-bindings: iio: health: maxim,max30102: fix compatible check · 4b71dbe4
      Javier Carrasco authored
      commit 89384a2b upstream.
      
      The "maxim,green-led-current-microamp" property is only available for
      the max30105 part (it provides an extra green LED), and must be set to
      false for the max30102 part.
      
      Instead, the max30100 part has been used for that, which is not
      supported by this binding (it has its own binding).
      
      This error was introduced during the txt to yaml conversion.
      
      Fixes: 5a6a65b1
      
       ("dt-bindings:iio:health:maxim,max30102: txt to yaml conversion")
      Signed-off-by: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
      Acked-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20240316-max30102_binding_fix-v1-1-e8e58f69ef8a@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b71dbe4
    • Paolo Abeni's avatar
      mptcp: ensure snd_nxt is properly initialized on connect · 39ca83ed
      Paolo Abeni authored
      commit fb7a0d33 upstream.
      
      Christoph reported a splat hinting at a corrupted snd_una:
      
        WARNING: CPU: 1 PID: 38 at net/mptcp/protocol.c:1005 __mptcp_clean_una+0x4b3/0x620 net/mptcp/protocol.c:1005
        Modules linked in:
        CPU: 1 PID: 38 Comm: kworker/1:1 Not tainted 6.9.0-rc1-gbbeac67456c9 #59
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014
        Workqueue: events mptcp_worker
        RIP: 0010:__mptcp_clean_una+0x4b3/0x620 net/mptcp/protocol.c:1005
        Code: be 06 01 00 00 bf 06 01 00 00 e8 a8 12 e7 fe e9 00 fe ff ff e8
        	8e 1a e7 fe 0f b7 ab 3e 02 00 00 e9 d3 fd ff ff e8 7d 1a e7 fe
        	<0f> 0b 4c 8b bb e0 05 00 00 e9 74 fc ff ff e8 6a 1a e7 fe 0f 0b e9
        RSP: 0018:ffffc9000013fd48 EFLAGS: 00010293
        RAX: 0000000000000000 RBX: ffff8881029bd280 RCX: ffffffff82382fe4
        RDX: ffff8881003cbd00 RSI: ffffffff823833c3 RDI: 0000000000000001
        RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
        R10: 0000000000000000 R11: fefefefefefefeff R12: ffff888138ba8000
        R13: 0000000000000106 R14: ffff8881029bd908 R15: ffff888126560000
        FS:  0000000000000000(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f604a5dae38 CR3: 0000000101dac002 CR4: 0000000000170ef0
        Call Trace:
         <TASK>
         __mptcp_clean_una_wakeup net/mptcp/protocol.c:1055 [inline]
         mptcp_clean_una_wakeup net/mptcp/protocol.c:1062 [inline]
         __mptcp_retrans+0x7f/0x7e0 net/mptcp/protocol.c:2615
         mptcp_worker+0x434/0x740 net/mptcp/protocol.c:2767
         process_one_work+0x1e0/0x560 kernel/workqueue.c:3254
         process_scheduled_works kernel/workqueue.c:3335 [inline]
         worker_thread+0x3c7/0x640 kernel/workqueue.c:3416
         kthread+0x121/0x170 kernel/kthread.c:388
         ret_from_fork+0x44/0x50 arch/x86/kernel/process.c:147
         ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
         </TASK>
      
      When fallback to TCP happens early on a client socket, snd_nxt
      is not yet initialized and any incoming ack will copy such value
      into snd_una. If the mptcp worker (dumbly) tries mptcp-level
      re-injection after such ack, that would unconditionally trigger a send
      buffer cleanup using 'bad' snd_una values.
      
      We could easily disable re-injection for fallback sockets, but such
      dumb behavior already helped catching a few subtle issues and a very
      low to zero impact in practice.
      
      Instead address the issue always initializing snd_nxt (and write_seq,
      for consistency) at connect time.
      
      Fixes: 8fd73804
      
       ("mptcp: fallback in case of simultaneous connect")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/485
      Tested-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
      Link: https://lore.kernel.org/r/20240429-upstream-net-20240429-mptcp-snd_nxt-init-connect-v1-1-59ceac0a7dcb@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39ca83ed
    • Dan Carpenter's avatar
      mm/slab: make __free(kfree) accept error pointers · 9f6eb0ab
      Dan Carpenter authored
      commit cd7eb8f8 upstream.
      
      Currently, if an automatically freed allocation is an error pointer that
      will lead to a crash.  An example of this is in wm831x_gpio_dbg_show().
      
         171	char *label __free(kfree) = gpiochip_dup_line_label(chip, i);
         172	if (IS_ERR(label)) {
         173		dev_err(wm831x->dev, "Failed to duplicate label\n");
         174		continue;
         175  }
      
      The auto clean up function should check for error pointers as well,
      otherwise we're going to keep hitting issues like this.
      
      Fixes: 54da6a09
      
       ("locking: Introduce __cleanup() based infrastructure")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f6eb0ab
    • Dominique Martinet's avatar
      btrfs: add missing mutex_unlock in btrfs_relocate_sys_chunks() · 25090e9b
      Dominique Martinet authored
      commit 9af503d9
      
       upstream.
      
      The previous patch that replaced BUG_ON by error handling forgot to
      unlock the mutex in the error path.
      
      Link: https://lore.kernel.org/all/Zh%2fHpAGFqa7YAFuM@duo.ucw.cz
      Reported-by: default avatarPavel Machek <pavel@denx.de>
      Fixes: 7411055d
      
       ("btrfs: handle chunk tree lookup error in btrfs_relocate_sys_chunks()")
      CC: stable@vger.kernel.org
      Reviewed-by: default avatarPavel Machek <pavel@denx.de>
      Signed-off-by: default avatarDominique Martinet <dominique.martinet@atmark-techno.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25090e9b
    • Aman Dhoot's avatar
      ALSA: hda/realtek: Fix mute led of HP Laptop 15-da3001TU · f0c6aae9
      Aman Dhoot authored
      commit 2d5af3ab
      
       upstream.
      
      This patch simply add SND_PCI_QUIRK for HP Laptop 15-da3001TU to fixed
      mute led of laptop.
      
      Signed-off-by: default avatarAman Dhoot <amandhoot12@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAMTp=B+3NG65Z684xMwHqdXDJhY+DJK-kuSw4adn6xwnG+b5JA@mail.gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0c6aae9
    • Badhri Jagan Sridharan's avatar
      usb: typec: tcpm: Check for port partner validity before consuming it · d56d2ca0
      Badhri Jagan Sridharan authored
      commit ae11f04b upstream.
      
      typec_register_partner() does not guarantee partner registration
      to always succeed. In the event of failure, port->partner is set
      to the error value or NULL. Given that port->partner validity is
      not checked, this results in the following crash:
      
      Unable to handle kernel NULL pointer dereference at virtual address xx
       pc : run_state_machine+0x1bc8/0x1c08
       lr : run_state_machine+0x1b90/0x1c08
      ..
       Call trace:
         run_state_machine+0x1bc8/0x1c08
         tcpm_state_machine_work+0x94/0xe4
         kthread_worker_fn+0x118/0x328
         kthread+0x1d0/0x23c
         ret_from_fork+0x10/0x20
      
      To prevent the crash, check for port->partner validity before
      derefencing it in all the call sites.
      
      Cc: stable@vger.kernel.org
      Fixes: c97cd0b4
      
       ("usb: typec: tcpm: set initial svdm version based on pd revision")
      Signed-off-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Link: https://lore.kernel.org/r/20240427202812.3435268-1-badhri@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d56d2ca0
    • Amit Sunil Dhamne's avatar
      usb: typec: tcpm: unregister existing source caps before re-registration · cfcd544a
      Amit Sunil Dhamne authored
      commit 230ecdf7 upstream.
      
      Check and unregister existing source caps in tcpm_register_source_caps
      function before registering new ones. This change fixes following
      warning when port partner resends source caps after negotiating PD contract
      for the purpose of re-negotiation.
      
      [  343.135030][  T151] sysfs: cannot create duplicate filename '/devices/virtual/usb_power_delivery/pd1/source-capabilities'
      [  343.135071][  T151] Call trace:
      [  343.135076][  T151]  dump_backtrace+0xe8/0x108
      [  343.135099][  T151]  show_stack+0x18/0x24
      [  343.135106][  T151]  dump_stack_lvl+0x50/0x6c
      [  343.135119][  T151]  dump_stack+0x18/0x24
      [  343.135126][  T151]  sysfs_create_dir_ns+0xe0/0x140
      [  343.135137][  T151]  kobject_add_internal+0x228/0x424
      [  343.135146][  T151]  kobject_add+0x94/0x10c
      [  343.135152][  T151]  device_add+0x1b0/0x4c0
      [  343.135187][  T151]  device_register+0x20/0x34
      [  343.135195][  T151]  usb_power_delivery_register_capabilities+0x90/0x20c
      [  343.135209][  T151]  tcpm_pd_rx_handler+0x9f0/0x15b8
      [  343.135216][  T151]  kthread_worker_fn+0x11c/0x260
      [  343.135227][  T151]  kthread+0x114/0x1bc
      [  343.135235][  T151]  ret_from_fork+0x10/0x20
      [  343.135265][  T151] kobject: kobject_add_internal failed for source-capabilities with -EEXIST, don't try to register things with the same name in the same directory.
      
      Fixes: 8203d269
      
       ("usb: typec: tcpm: Register USB Power Delivery Capabilities")
      Cc: linux-usb@vger.kernel.org
      Cc: stable@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Cc: Mark Brown <broonie@kernel.org>
      Signed-off-by: default avatarAmit Sunil Dhamne <amitsd@google.com>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/20240424223227.1807844-1-amitsd@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cfcd544a
    • Thinh Nguyen's avatar
      usb: dwc3: core: Prevent phy suspend during init · d9efd3c8
      Thinh Nguyen authored
      commit 6d735722 upstream.
      
      GUSB3PIPECTL.SUSPENDENABLE and GUSB2PHYCFG.SUSPHY should be cleared
      during initialization. Suspend during initialization can result in
      undefined behavior due to clock synchronization failure, which often
      seen as core soft reset timeout.
      
      The programming guide recommended these bits to be cleared during
      initialization for DWC_usb3.0 version 1.94 and above (along with
      DWC_usb31 and DWC_usb32). The current check in the driver does not
      account if it's set by default setting from coreConsultant.
      
      This is especially the case for DRD when switching mode to ensure the
      phy clocks are available to change mode. Depending on the
      platforms/design, some may be affected more than others. This is noted
      in the DWC_usb3x programming guide under the above registers.
      
      Let's just disable them during driver load and mode switching. Restore
      them when the controller initialization completes.
      
      Note that some platforms workaround this issue by disabling phy suspend
      through "snps,dis_u3_susphy_quirk" and "snps,dis_u2_susphy_quirk" when
      they should not need to.
      
      Cc: stable@vger.kernel.org
      Fixes: 9ba3aca8
      
       ("usb: dwc3: Disable phy suspend after power-on reset")
      Signed-off-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
      Link: https://lore.kernel.org/r/20da4e5a0c4678c9587d3da23f83bdd6d77353e9.1713394973.git.Thinh.Nguyen@synopsys.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9efd3c8
    • Thinh Nguyen's avatar
      usb: xhci-plat: Don't include xhci.h · bf3b0ab6
      Thinh Nguyen authored
      commit 4a237d55
      
       upstream.
      
      The xhci_plat.h should not need to include the entire xhci.h header.
      This can cause redefinition in dwc3 if it selectively includes some xHCI
      definitions. This is a prerequisite change for a fix to disable suspend
      during initialization for dwc3.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
      Link: https://lore.kernel.org/r/310acfa01c957a10d9feaca3f7206269866ba2eb.1713394973.git.Thinh.Nguyen@synopsys.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf3b0ab6
    • Chris Wulff's avatar
      usb: gadget: f_fs: Fix a race condition when processing setup packets. · 4e2ae9ff
      Chris Wulff authored
      commit 0aea736d upstream.
      
      If the USB driver passes a pointer into the TRB buffer for creq, this
      buffer can be overwritten with the status response as soon as the event
      is queued. This can make the final check return USB_GADGET_DELAYED_STATUS
      when it shouldn't. Instead use the stored wLength.
      
      Fixes: 4d644abf
      
       ("usb: gadget: f_fs: Only return delayed status when len is 0")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarChris Wulff <chris.wulff@biamp.com>
      Link: https://lore.kernel.org/r/CO1PR17MB5419BD664264A558B2395E28E1112@CO1PR17MB5419.namprd17.prod.outlook.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e2ae9ff
    • Peter Korsgaard's avatar
      usb: gadget: composite: fix OS descriptors w_value logic · 9dac7678
      Peter Korsgaard authored
      commit ec6ce707 upstream.
      
      The OS descriptors logic had the high/low byte of w_value inverted, causing
      the extended properties to not be accessible for interface != 0.
      
      >From the Microsoft documentation:
      https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-os-1-0-descriptors-specification
      
      OS_Desc_CompatID.doc (w_index = 0x4):
      
      - wValue:
      
        High Byte = InterfaceNumber.  InterfaceNumber is set to the number of the
        interface or function that is associated with the descriptor, typically
        0x00.  Because a device can have only one extended compat ID descriptor,
        it should ignore InterfaceNumber, regardless of the value, and simply
        return the descriptor.
      
        Low Byte = 0.  PageNumber is used to retrieve descriptors that are larger
        than 64 KB.  The header section is 16 bytes, so PageNumber is set to 0 for
        this request.
      
      We currently do not support >64KB compat ID descriptors, so verify that the
      low byte is 0.
      
      OS_Desc_Ext_Prop.doc (w_index = 0x5):
      
      - wValue:
      
        High byte = InterfaceNumber.  The high byte of wValue is set to the number
        of the interface or function that is associated with the descriptor.
      
        Low byte = PageNumber.  The low byte of wValue is used to retrieve
        descriptors that are larger than 64 KB.  The header section is 10 bytes, so
        PageNumber is set to 0 for this request.
      
      We also don't support >64KB extended properties, so verify that the low byte
      is 0 and use the high byte for the interface number.
      
      Fixes: 37a3a533
      
       ("usb: gadget: OS Feature Descriptors support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarPeter Korsgaard <peter@korsgaard.com>
      Link: https://lore.kernel.org/r/20240404100635.3215340-1-peter@korsgaard.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9dac7678
    • Alan Stern's avatar
      USB: core: Fix access violation during port device removal · 5f1d68ef
      Alan Stern authored
      commit a4b46d45
      
       upstream.
      
      Testing with KASAN and syzkaller revealed a bug in port.c:disable_store():
      usb_hub_to_struct_hub() can return NULL if the hub that the port belongs to
      is concurrently removed, but the function does not check for this
      possibility before dereferencing the returned value.
      
      It turns out that the first dereference is unnecessary, since hub->intfdev
      is the parent of the port device, so it can be changed easily.  Adding a
      check for hub == NULL prevents further problems.
      
      The same bug exists in the disable_show() routine, and it can be fixed the
      same way.
      
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: default avatarYue Sun <samsun1006219@gmail.com>
      Reported-by: default avatarxingwei lee <xrivendell7@gmail.com>
      Link: https://lore.kernel.org/linux-usb/CAEkJfYON+ry7xPx=AiLR9jzUNT+i_Va68ACajOC3HoacOfL1ig@mail.gmail.com/
      Fixes: f061f43d
      
       ("usb: hub: port: add sysfs entry to switch port power")
      CC: Michael Grzeschik <m.grzeschik@pengutronix.de>
      CC: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/393aa580-15a5-44ca-ad3b-6462461cd313@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5f1d68ef
    • Guenter Roeck's avatar
      usb: ohci: Prevent missed ohci interrupts · 3e7bbab8
      Guenter Roeck authored
      commit fe81f354 upstream.
      
      Testing ohci functionality with qemu's pci-ohci emulation often results
      in ohci interface stalls, resulting in hung task timeouts.
      
      The problem is caused by lost interrupts between the emulation and the
      Linux kernel code. Additional interrupts raised while the ohci interrupt
      handler in Linux is running and before the handler clears the interrupt
      status are not handled. The fix for a similar problem in ehci suggests
      that the problem is likely caused by edge-triggered MSI interrupts. See
      commit 0b605572 ("usb: ehci: Prevent missed ehci interrupts with
      edge-triggered MSI") for details.
      
      Ensure that the ohci interrupt code handles all pending interrupts before
      returning to solve the problem.
      
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: David Laight <David.Laight@aculab.com>
      Cc: stable@vger.kernel.org
      Fixes: 306c54d0
      
       ("usb: hcd: Try MSI interrupts on PCI devices")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Link: https://lore.kernel.org/r/20240429154010.1507366-1-linux@roeck-us.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e7bbab8
    • Alan Stern's avatar
      usb: Fix regression caused by invalid ep0 maxpacket in virtual SuperSpeed device · 32a22b9f
      Alan Stern authored
      commit c78c3644
      
       upstream.
      
      A virtual SuperSpeed device in the FreeBSD BVCP package
      (https://bhyve.npulse.net/) presents an invalid ep0 maxpacket size of 256.
      It stopped working with Linux following a recent commit because now we
      check these sizes more carefully than before.
      
      Fix this regression by using the bMaxpacketSize0 value in the device
      descriptor for SuperSpeed or faster devices, even if it is invalid.  This
      is a very simple-minded change; we might want to check more carefully for
      values that actually make some sense (for instance, no smaller than 64).
      
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: default avatarRoger Whittaker <roger.whittaker@suse.com>
      Closes: https://bugzilla.suse.com/show_bug.cgi?id=1220569
      Link: https://lore.kernel.org/linux-usb/9efbd569-7059-4575-983f-0ea30df41871@suse.com/
      Fixes: 59cf4457
      
       ("USB: core: Fix oversight in SuperSpeed initialization")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/4058ac05-237c-4db4-9ecc-5af42bdb4501@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      32a22b9f
    • Christian A. Ehrhardt's avatar
      usb: typec: ucsi: Fix connector check on init · 85e6aa4f
      Christian A. Ehrhardt authored
      commit ce4c8d21 upstream.
      
      Fix issues when initially checking for a connector change:
      - Use the correct connector number not the entire CCI.
      - Call ->read under the PPM lock.
      - Remove a bogus READ_ONCE.
      
      Fixes: 808a8b9e
      
       ("usb: typec: ucsi: Check for notifications after init")
      Cc: stable@kernel.org
      Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/20240401210515.1902048-1-lk@c--e.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85e6aa4f
    • Christian A. Ehrhardt's avatar
      usb: typec: ucsi: Check for notifications after init · 91a7af8c
      Christian A. Ehrhardt authored
      commit 808a8b9e upstream.
      
      The completion notification for the final SET_NOTIFICATION_ENABLE
      command during initialization can include a connector change
      notification.  However, at the time this completion notification is
      processed, the ucsi struct is not ready to handle this notification.
      As a result the notification is ignored and the controller
      never sends an interrupt again.
      
      Re-check CCI for a pending connector state change after
      initialization is complete. Adjust the corresponding debug
      message accordingly.
      
      Fixes: 71a1fa0d
      
       ("usb: typec: ucsi: Store the notification mask")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
      Link: https://lore.kernel.org/r/20240320073927.1641788-3-lk@c--e.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91a7af8c
    • Benno Lossin's avatar
      rust: macros: fix soundness issue in `module!` macro · 398248fc
      Benno Lossin authored
      commit 7044dcff
      
       upstream.
      
      The `module!` macro creates glue code that are called by C to initialize
      the Rust modules using the `Module::init` function. Part of this glue
      code are the local functions `__init` and `__exit` that are used to
      initialize/destroy the Rust module.
      
      These functions are safe and also visible to the Rust mod in which the
      `module!` macro is invoked. This means that they can be called by other
      safe Rust code. But since they contain `unsafe` blocks that rely on only
      being called at the right time, this is a soundness issue.
      
      Wrap these generated functions inside of two private modules, this
      guarantees that the public functions cannot be called from the outside.
      Make the safe functions `unsafe` and add SAFETY comments.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarBjörn Roy Baron <bjorn3_gh@protonmail.com>
      Closes: https://github.com/Rust-for-Linux/linux/issues/629
      Fixes: 1fbde52b
      
       ("rust: add `macros` crate")
      Signed-off-by: default avatarBenno Lossin <benno.lossin@proton.me>
      Reviewed-by: default avatarWedson Almeida Filho <walmeida@microsoft.com>
      Link: https://lore.kernel.org/r/20240401185222.12015-1-benno.lossin@proton.me
      [ Moved `THIS_MODULE` out of the private-in-private modules since it
        should remain public, as Dirk Behme noticed [1]. Capitalized comments,
        avoided newline in non-list SAFETY comments and reworded to add
        Reported-by and newline. ]
      Link: https://rust-for-linux.zulipchat.com/#narrow/stream/291565-Help/topic/x/near/433512583 [1]
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      398248fc
    • Thomas Bertschinger's avatar
      rust: module: place generated init_module() function in .init.text · ca99731c
      Thomas Bertschinger authored
      commit 1b6170ff
      
       upstream.
      
      Currently Rust kernel modules have their init code placed in the `.text`
      section of the .ko file. I don't think this causes any real problems
      for Rust modules as long as all code called during initialization lives
      in `.text`.
      
      However, if a Rust `init_module()` function (that lives in `.text`)
      calls a function marked with `__init` (in C) or
      `#[link_section = ".init.text"]` (in Rust), then a warning is
      generated by modpost because that function lives in `.init.text`.
      For example:
      
      WARNING: modpost: fs/bcachefs/bcachefs: section mismatch in reference: init_module+0x6 (section: .text) -> _RNvXCsj7d3tFpT5JS_15bcachefs_moduleNtB2_8BcachefsNtCsjDtqRIL3JAG_6kernel6Module4init (section: .init.text)
      
      I ran into this while experimenting with converting the bcachefs kernel
      module from C to Rust. The module's `init()`, written in Rust, calls C
      functions like `bch2_vfs_init()` which are placed in `.init.text`.
      
      This patch places the macro-generated `init_module()` Rust function in
      the `.init.text` section. It also marks `init_module()` as unsafe--now
      it may not be called after module initialization completes because it
      may be freed already.
      
      Note that this is not enough on its own to actually get all the module
      initialization code in that section. The module author must still add
      the `#[link_section = ".init.text"]` attribute to the Rust `init()` in
      the `impl kernel::Module` block in order to then call `__init`
      functions. However, this patch enables module authors do so, when
      previously it would not be possible (without warnings).
      
      Signed-off-by: default avatarThomas Bertschinger <tahbertschinger@gmail.com>
      Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
      Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
      Link: https://lore.kernel.org/r/20240206153806.567055-1-tahbertschinger@gmail.com
      [ Reworded title to add prefix. ]
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca99731c
    • Andrea Righi's avatar
      btf, scripts: rust: drop is_rust_module.sh · 15eb8edb
      Andrea Righi authored
      commit 41bdc6de upstream.
      
      With commit c1177979
      
       ("btf, scripts: Exclude Rust CUs with pahole")
      we are now able to use pahole directly to identify Rust compilation
      units (CUs) and exclude them from generating BTF debugging information
      (when DEBUG_INFO_BTF is enabled).
      
      And if pahole doesn't support the --lang-exclude flag, we can't enable
      both RUST and DEBUG_INFO_BTF at the same time.
      
      So, in any case, the script is_rust_module.sh is just redundant and we
      can drop it.
      
      NOTE: we may also be able to drop the "Rust loadable module" mark
      inside Rust modules, but it seems safer to keep it for now to make sure
      we are not breaking any external tool that may potentially rely on it.
      
      Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarEric Curtin <ecurtin@redhat.com>
      Reviewed-by: default avatarEric Curtin <ecurtin@redhat.com>
      Reviewed-by: default avatarNeal Gompa <neal@gompa.dev>
      Reviewed-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
      Acked-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
      Link: https://lore.kernel.org/r/20230704052136.155445-1-andrea.righi@canonical.com
      [ Picked the `Reviewed-by`s from the old patch too. ]
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15eb8edb
    • Andrea Righi's avatar
      rust: fix regexp in scripts/is_rust_module.sh · 0a0464cd
      Andrea Righi authored
      commit ccc45054
      
       upstream.
      
      nm can use "R" or "r" to show read-only data sections, but
      scripts/is_rust_module.sh can only recognize "r", so with some versions
      of binutils it can fail to detect if a module is a Rust module or not.
      
      Right now we're using this script only to determine if we need to skip
      BTF generation (that is disabled globally if CONFIG_RUST is enabled),
      but it's still nice to fix this script to do the proper job.
      
      Moreover, with this patch applied I can also relax the constraint of
      "RUST depends on !DEBUG_INFO_BTF" and build a kernel with Rust and BTF
      enabled at the same time (of course BTF generation is still skipped for
      Rust modules).
      
      [ Miguel: The actual reason is likely to be a change on the Rust
        compiler between 1.61.0 and 1.62.0:
      
          echo '#[used] static S: () = ();' |
              rustup run 1.61.0 rustc --emit=obj --crate-type=lib - &&
              nm rust_out.o
      
          echo '#[used] static S: () = ();' |
              rustup run 1.62.0 rustc --emit=obj --crate-type=lib - &&
              nm rust_out.o
      
        Gives:
      
          0000000000000000 r _ZN8rust_out1S17h48027ce0da975467E
          0000000000000000 R _ZN8rust_out1S17h58e1f3d9c0e97cefE
      
        See https://godbolt.org/z/KE6jneoo4. ]
      
      Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
      Reviewed-by: default avatarVincenzo Palazzo <vincenzopalazzodev@gmail.com>
      Reviewed-by: default avatarEric Curtin <ecurtin@redhat.com>
      Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0a0464cd
    • Asahi Lina's avatar
      rust: error: Rename to_kernel_errno() -> to_errno() · 8762bf94
      Asahi Lina authored
      commit 46384d09
      
       upstream.
      
      This is kernel code, so specifying "kernel" is redundant. Let's simplify
      things and just call it to_errno().
      
      Reviewed-by: default avatarGary Guo <gary@garyguo.net>
      Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
      Signed-off-by: default avatarAsahi Lina <lina@asahilina.net>
      Link: https://lore.kernel.org/r/20230224-rust-error-v3-1-03779bddc02b@asahilina.net
      Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8762bf94
    • Linus Torvalds's avatar
      Reapply "drm/qxl: simplify qxl_fence_wait" · b548c53b
      Linus Torvalds authored
      commit 3628e038 upstream.
      
      This reverts commit 07ed11af
      
      .
      
      Stephen Rostedt reports:
       "I went to run my tests on my VMs and the tests hung on boot up.
        Unfortunately, the most I ever got out was:
      
        [   93.607888] Testing event system initcall: OK
        [   93.667730] Running tests on all trace events:
        [   93.669757] Testing all events: OK
        [   95.631064] ------------[ cut here ]------------
        Timed out after 60 seconds"
      
      and further debugging points to a possible circular locking dependency
      between the console_owner locking and the worker pool locking.
      
      Reverting the commit allows Steve's VM to boot to completion again.
      
      [ This may obviously result in the "[TTM] Buffer eviction failed"
        messages again, which was the reason for that original revert. But at
        this point this seems preferable to a non-booting system... ]
      
      Reported-and-bisected-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Link: https://lore.kernel.org/all/20240502081641.457aa25f@gandalf.local.home/
      Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
      Cc: Alex Constantino <dreaming.about.electric.sheep@gmail.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Timo Lindfors <timo.lindfors@iki.fi>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b548c53b
    • Thanassis Avgerinos's avatar
      firewire: nosy: ensure user_length is taken into account when fetching packet contents · 4ee0941d
      Thanassis Avgerinos authored
      commit 38762a07
      
       upstream.
      
      Ensure that packet_buffer_get respects the user_length provided. If
      the length of the head packet exceeds the user_length, packet_buffer_get
      will now return 0 to signify to the user that no data were read
      and a larger buffer size is required. Helps prevent user space overflows.
      
      Signed-off-by: default avatarThanassis Avgerinos <thanassis.avgerinos@gmail.com>
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ee0941d
    • Dmitry Antipov's avatar
      btrfs: fix kvcalloc() arguments order in btrfs_ioctl_send() · 53f2bfce
      Dmitry Antipov authored
      commit 6ff09b6b
      
       upstream.
      
      When compiling with gcc version 14.0.0 20231220 (experimental)
      and W=1, I've noticed the following warning:
      
      fs/btrfs/send.c: In function 'btrfs_ioctl_send':
      fs/btrfs/send.c:8208:44: warning: 'kvcalloc' sizes specified with 'sizeof'
      in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
       8208 |         sctx->clone_roots = kvcalloc(sizeof(*sctx->clone_roots),
            |                                            ^
      
      Since 'n' and 'size' arguments of 'kvcalloc()' are multiplied to
      calculate the final size, their actual order doesn't affect the result
      and so this is not a bug. But it's still worth to fix it.
      
      Signed-off-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      53f2bfce
    • Christian König's avatar
      drm/amdgpu: once more fix the call oder in amdgpu_ttm_move() v2 · 5c25b169
      Christian König authored
      commit d3a9331a
      
       upstream.
      
      This reverts drm/amdgpu: fix ftrace event amdgpu_bo_move always move
      on same heap. The basic problem here is that after the move the old
      location is simply not available any more.
      
      Some fixes were suggested, but essentially we should call the move
      notification before actually moving things because only this way we have
      the correct order for DMA-buf and VM move notifications as well.
      
      Also rework the statistic handling so that we don't update the eviction
      counter before the move.
      
      v2: add missing NULL check
      
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Fixes: 94aeb411
      
       ("drm/amdgpu: fix ftrace event amdgpu_bo_move always move on same heap")
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3171
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c25b169