<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/gpio, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>gpio: shared-proxy: propagate -ENOTSUPP from .set_config()</title>
<updated>2026-11-20T12:36:53+00:00</updated>
<author>
<name>Bartosz Golaszewski</name>
<email>bartosz.golaszewski@oss.qualcomm.com</email>
</author>
<published>2026-11-18T12:45:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=31678e68f82636a27fbad58ae40054557da4fd7e'/>
<id>31678e68f82636a27fbad58ae40054557da4fd7e</id>
<content type='text'>
The gpio-shared-proxy driver does not propagate -ENOTSUPP returned from
the set_config() callback by real GPIO drivers controlling the shared
GPIOs. This can lead to a situation where for an open-drain, shared GPIO,
we take the emulation path on request - ending up setting the direction
to input for the initial user - and then fail to allow simulated output
direction for the second user if the driver in question does not
support using "real" open-drain.

Propagate all errors from the underlying .set_config() call in
gpio_shared_proxy_set_config().

Reported-by: Igor Velkov &lt;iav@iav.lv&gt;
Closes: https://lore.kernel.org/all/20261115-hc4-gpio-shared-od-1@iav.lv/
Fixes: e992d54c6f97 ("gpio: shared-proxy: implement the shared GPIO proxy driver")
Tested-by: Igor Velkov &lt;iav@iav.lv&gt;
Link: https://patch.msgid.link/20261118-gpio-shared-proxy-enotsupp-v1-1-39d3fe4d3aa7@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The gpio-shared-proxy driver does not propagate -ENOTSUPP returned from
the set_config() callback by real GPIO drivers controlling the shared
GPIOs. This can lead to a situation where for an open-drain, shared GPIO,
we take the emulation path on request - ending up setting the direction
to input for the initial user - and then fail to allow simulated output
direction for the second user if the driver in question does not
support using "real" open-drain.

Propagate all errors from the underlying .set_config() call in
gpio_shared_proxy_set_config().

Reported-by: Igor Velkov &lt;iav@iav.lv&gt;
Closes: https://lore.kernel.org/all/20261115-hc4-gpio-shared-od-1@iav.lv/
Fixes: e992d54c6f97 ("gpio: shared-proxy: implement the shared GPIO proxy driver")
Tested-by: Igor Velkov &lt;iav@iav.lv&gt;
Link: https://patch.msgid.link/20261118-gpio-shared-proxy-enotsupp-v1-1-39d3fe4d3aa7@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: omap: handle debounce clock preparation failure</title>
<updated>2026-11-19T10:34:30+00:00</updated>
<author>
<name>Jiawen Liu</name>
<email>1298662399@qq.com</email>
</author>
<published>2026-11-09T13:42:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9df982f1f283d2f2a9aad764dff92e36ed764e16'/>
<id>9df982f1f283d2f2a9aad764dff92e36ed764e16</id>
<content type='text'>
omap_gpio_probe() ignores the return value of clk_prepare() for the
debounce clock. If preparation fails, the driver still treats debounce as
available and may use or unprepare a clock that was not prepared.

Use devm_clk_get_prepared() and disable debounce if the clock cannot be
obtained or prepared. This keeps the existing behavior for clock lookup
failures. Remove both manual clk_unprepare() calls because the managed
clock is released on probe failure and device removal.

Fixes: 5d9452e7c52a ("gpio: omap: fix clk_prepare/unprepare usage")
Suggested-by: Andreas Kemnade &lt;andreas@kemnade.info&gt;
Link: https://lore.kernel.org/r/tencent_B4F504456790E8BA3C4EAB80F4BFB6954E08@qq.com
Link: https://lkml.rescloud.iu.edu/hypermail/linux/kernel/2412.2/00414.html
Signed-off-by: Jiawen Liu &lt;1298662399@qq.com&gt;
Reviewed-by: Linus Walleij &lt;linusw@kernel.org&gt;
Reviewed-by: Alexander Sverdlin &lt;alexander.sverdlin@siemens.com&gt;
Tested-by: Alexander Sverdlin &lt;alexander.sverdlin@siemens.com&gt;
Link: https://patch.msgid.link/tencent_D8A4B6EE90931660EB6F586543FD58110E06@qq.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
omap_gpio_probe() ignores the return value of clk_prepare() for the
debounce clock. If preparation fails, the driver still treats debounce as
available and may use or unprepare a clock that was not prepared.

Use devm_clk_get_prepared() and disable debounce if the clock cannot be
obtained or prepared. This keeps the existing behavior for clock lookup
failures. Remove both manual clk_unprepare() calls because the managed
clock is released on probe failure and device removal.

Fixes: 5d9452e7c52a ("gpio: omap: fix clk_prepare/unprepare usage")
Suggested-by: Andreas Kemnade &lt;andreas@kemnade.info&gt;
Link: https://lore.kernel.org/r/tencent_B4F504456790E8BA3C4EAB80F4BFB6954E08@qq.com
Link: https://lkml.rescloud.iu.edu/hypermail/linux/kernel/2412.2/00414.html
Signed-off-by: Jiawen Liu &lt;1298662399@qq.com&gt;
Reviewed-by: Linus Walleij &lt;linusw@kernel.org&gt;
Reviewed-by: Alexander Sverdlin &lt;alexander.sverdlin@siemens.com&gt;
Tested-by: Alexander Sverdlin &lt;alexander.sverdlin@siemens.com&gt;
Link: https://patch.msgid.link/tencent_D8A4B6EE90931660EB6F586543FD58110E06@qq.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: mpsse: reject bulk-in endpoints smaller than 3 bytes</title>
<updated>2026-11-19T10:33:36+00:00</updated>
<author>
<name>Hyunjung Ko</name>
<email>hj351016@gmail.com</email>
</author>
<published>2026-11-17T10:41:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f94f85f82e042c89a1e64ed3ff1d591a2bccfa7b'/>
<id>f94f85f82e042c89a1e64ed3ff1d591a2bccfa7b</id>
<content type='text'>
mpsse_read() reads min(len + 2, wMaxPacketSize) bytes and then copies
len_actual - 2 bytes to the caller. A device that declares a bulk-in
endpoint with wMaxPacketSize 1 completes the read with len_actual 1, so
the copy length becomes -1 and memcpy() runs far past the one byte
buffer on the caller's stack and past bulk_in_buf:

  memcpy: detected buffer overflow: 18446744073709551615 byte write of buffer size 1
  WARNING: lib/string_helpers.c:1036 at __fortify_report+0x6e/0xc0
  Call Trace:
   __fortify_panic+0xd/0x10
   gpio_mpsse_get_multiple+0x767/0x780
   gpio_mpsse_gpio_get+0xa2/0xf0
   gpiod_get_raw_value_commit+0xf8/0x1f0
   gpiod_get_value_cansleep+0x1e/0xa0
   value_show+0x42/0x90

Reproduced with dummy_hcd and raw-gadget. A read needs room for the two
status bytes plus at least one data byte, so refuse to bind otherwise.

Fixes: c46a74ff05c0 ("gpio: add support for FTDI's MPSSE as GPIO")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko &lt;hj351016@gmail.com&gt;
Link: https://patch.msgid.link/20261117104110.240112-1-hj351016@gmail.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mpsse_read() reads min(len + 2, wMaxPacketSize) bytes and then copies
len_actual - 2 bytes to the caller. A device that declares a bulk-in
endpoint with wMaxPacketSize 1 completes the read with len_actual 1, so
the copy length becomes -1 and memcpy() runs far past the one byte
buffer on the caller's stack and past bulk_in_buf:

  memcpy: detected buffer overflow: 18446744073709551615 byte write of buffer size 1
  WARNING: lib/string_helpers.c:1036 at __fortify_report+0x6e/0xc0
  Call Trace:
   __fortify_panic+0xd/0x10
   gpio_mpsse_get_multiple+0x767/0x780
   gpio_mpsse_gpio_get+0xa2/0xf0
   gpiod_get_raw_value_commit+0xf8/0x1f0
   gpiod_get_value_cansleep+0x1e/0xa0
   value_show+0x42/0x90

Reproduced with dummy_hcd and raw-gadget. A read needs room for the two
status bytes plus at least one data byte, so refuse to bind otherwise.

Fixes: c46a74ff05c0 ("gpio: add support for FTDI's MPSSE as GPIO")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunjung Ko &lt;hj351016@gmail.com&gt;
Link: https://patch.msgid.link/20261117104110.240112-1-hj351016@gmail.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: ljca: Validate the pin index of interrupt events</title>
<updated>2026-11-17T10:19:28+00:00</updated>
<author>
<name>Alexandre Becholey</name>
<email>alex@becholey.ch</email>
</author>
<published>2026-11-13T14:44:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e6e2181c6920ff59ded349a100f80cf85d074601'/>
<id>e6e2181c6920ff59ded349a100f80cf85d074601</id>
<content type='text'>
ljca_gpio_event_cb() takes the pin index of every item in a GPIO
interrupt event from the device and passes it to set_bit() on the
reenable_irqs bitmap, which is only LJCA_MAX_GPIO_NUM (64) bits long.
The index is a u8, so a malfunctioning or malicious device can set
bits past the end of the bitmap, in the members that follow it in
struct ljca_gpio_dev: the output_enabled bitmap, the connect_mode
pointer and the irq_lock mutex. connect_mode is later dereferenced and
written to by ljca_gpio_set_config() and ljca_irq_set_type(), so the
device can flip bits of a kernel pointer that is then used for a write.

Until commit 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
an index without an IRQ mapping made irq_find_mapping() fail and the
handler returned before set_bit(). Since that change nothing checks
the index.

A device bound to usb-ljca can trigger this by sending one GPIO
interrupt event, once the gpiochip is registered, with an index that
sets a bit of connect_mode which is still clear in a kernel pointer:
175 (bit 47) on arm64, 174 (bit 46) on x86_64. The next GPIO line
request then faults in ljca_gpio_set_config(). With dummy_hcd and
KASAN, on arm64 (torvalds/master 067c5c24cef2):

 Unable to handle kernel paging request at virtual address ffff7000023dfd30
 pc : ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

and on x86_64 (torvalds/master 7e1392a42ea2, nokaslr):

 BUG: unable to handle page fault for address: ffffc8800f5452b8
 RIP: 0010:ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

Ignore event items whose pin index is not below the number of GPIOs of
the chip. That number never exceeds LJCA_MAX_GPIO_NUM, because
usb-ljca rejects larger values at enumeration, so set_bit() stays
inside the bitmap. Valid items in the same event are still handled.

The bug was found by AI agents (Claude Mythos and Claude Opus models). The
analysis and the patch were reviewed by a human, who also reproduced the
bug on x86_64 and aarch64 with current master.

Fixes: 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Becholey &lt;alex@becholey.ch&gt;
Link: https://patch.msgid.link/20261113144432.1354180-1-alex@becholey.ch
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ljca_gpio_event_cb() takes the pin index of every item in a GPIO
interrupt event from the device and passes it to set_bit() on the
reenable_irqs bitmap, which is only LJCA_MAX_GPIO_NUM (64) bits long.
The index is a u8, so a malfunctioning or malicious device can set
bits past the end of the bitmap, in the members that follow it in
struct ljca_gpio_dev: the output_enabled bitmap, the connect_mode
pointer and the irq_lock mutex. connect_mode is later dereferenced and
written to by ljca_gpio_set_config() and ljca_irq_set_type(), so the
device can flip bits of a kernel pointer that is then used for a write.

Until commit 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
an index without an IRQ mapping made irq_find_mapping() fail and the
handler returned before set_bit(). Since that change nothing checks
the index.

A device bound to usb-ljca can trigger this by sending one GPIO
interrupt event, once the gpiochip is registered, with an index that
sets a bit of connect_mode which is still clear in a kernel pointer:
175 (bit 47) on arm64, 174 (bit 46) on x86_64. The next GPIO line
request then faults in ljca_gpio_set_config(). With dummy_hcd and
KASAN, on arm64 (torvalds/master 067c5c24cef2):

 Unable to handle kernel paging request at virtual address ffff7000023dfd30
 pc : ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

and on x86_64 (torvalds/master 7e1392a42ea2, nokaslr):

 BUG: unable to handle page fault for address: ffffc8800f5452b8
 RIP: 0010:ljca_gpio_set_config (drivers/gpio/gpio-ljca.c:212)

Ignore event items whose pin index is not below the number of GPIOs of
the chip. That number never exceeds LJCA_MAX_GPIO_NUM, because
usb-ljca rejects larger values at enumeration, so set_bit() stays
inside the bitmap. Valid items in the same event are still handled.

The bug was found by AI agents (Claude Mythos and Claude Opus models). The
analysis and the patch were reviewed by a human, who also reproduced the
bug on x86_64 and aarch64 with current master.

Fixes: 4c4e6ea4a120 ("gpio: ljca: Fix duplicated IRQ mapping")
Cc: stable@vger.kernel.org
Signed-off-by: Alexandre Becholey &lt;alex@becholey.ch&gt;
Link: https://patch.msgid.link/20261113144432.1354180-1-alex@becholey.ch
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpiolib: keep the line state workqueue alive until device release</title>
<updated>2026-11-17T08:32:59+00:00</updated>
<author>
<name>Bartosz Golaszewski</name>
<email>bartosz.golaszewski@oss.qualcomm.com</email>
</author>
<published>2026-11-10T09:29:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2e002a1d05b1979006f3c46eb6cb5cc36e5630ac'/>
<id>2e002a1d05b1979006f3c46eb6cb5cc36e5630ac</id>
<content type='text'>
gpiod_line_state_notify() races with a concurrent gpiochip_remove() which
unconditionally destroys the line state workqueue causing
a use-after-free situation where queue_work() can schedule a work on a
freed workqueue.

Keep the line state workqueue alive until GPIO device release.

Cc: stable@vger.kernel.org
Fixes: 07c61d4da43f ("gpiolib: notify user-space about in-kernel line state changes")
Closes: https://sashiko.dev/#/bug/linux-d0e9e518-2348-4fe3-857d-f3d61a42f159
Link: https://patch.msgid.link/20261110-gpio-line-state-wq-uaf-v2-1-ce6d8266656e@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
gpiod_line_state_notify() races with a concurrent gpiochip_remove() which
unconditionally destroys the line state workqueue causing
a use-after-free situation where queue_work() can schedule a work on a
freed workqueue.

Keep the line state workqueue alive until GPIO device release.

Cc: stable@vger.kernel.org
Fixes: 07c61d4da43f ("gpiolib: notify user-space about in-kernel line state changes")
Closes: https://sashiko.dev/#/bug/linux-d0e9e518-2348-4fe3-857d-f3d61a42f159
Link: https://patch.msgid.link/20261110-gpio-line-state-wq-uaf-v2-1-ce6d8266656e@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: mlxbf2: Disable interrupts around the chip lock in direction ops</title>
<updated>2026-11-17T08:30:24+00:00</updated>
<author>
<name>David Thompson</name>
<email>davthompson@nvidia.com</email>
</author>
<published>2026-11-13T18:44:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f95bdff1d53471159e3c7112c5de4f6240772521'/>
<id>f95bdff1d53471159e3c7112c5de4f6240772521</id>
<content type='text'>
mlxbf2_gpio_lock_acquire() takes the generic GPIO chip lock with
gpio_generic_chip_lock(), a plain raw_spin_lock() that leaves
interrupts enabled. The same lock is also taken with the irqsave
variant by the IRQ callbacks (irq_set_type, irq_enable, irq_disable),
which run with the IRQ descriptor lock held.

This creates a possible deadlock that lockdep reports as an IRQ lock
inversion:

  CPU0                              CPU1
  ----                              ----
  lock(&amp;chip-&gt;lock)                 lock(irq_desc-&gt;lock)
  &lt;GPIO interrupt&gt;                  lock(&amp;chip-&gt;lock)
    lock(irq_desc-&gt;lock)

If a GPIO interrupt arrives on CPU0 while it holds the chip lock during
a direction change, the interrupt handler spins on the descriptor lock
that CPU1 holds, while CPU1 spins on the chip lock held by CPU0.

This was seen during probe of pwr-mlxbf. acpi_dev_gpio_irq_get() sets
the pin to input through mlxbf2_gpio_direction_input(), and then
irq_set_irq_type() runs with the descriptor lock held.

Use the irqsave variant for the chip lock in mlxbf2_gpio_lock_acquire()
and its release counterpart, and pass the saved flags from
mlxbf2_gpio_direction_input() and mlxbf2_gpio_direction_output(). This
matches the IRQ callbacks, so interrupts stay disabled for the whole
ModeX update.

Fixes: 2b725265cb08 ("gpio: mlxbf2: Introduce IRQ support")
Cc: stable@vger.kernel.org
Signed-off-by: David Thompson &lt;davthompson@nvidia.com&gt;
Link: https://patch.msgid.link/20261113184444.3431-1-davthompson@nvidia.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mlxbf2_gpio_lock_acquire() takes the generic GPIO chip lock with
gpio_generic_chip_lock(), a plain raw_spin_lock() that leaves
interrupts enabled. The same lock is also taken with the irqsave
variant by the IRQ callbacks (irq_set_type, irq_enable, irq_disable),
which run with the IRQ descriptor lock held.

This creates a possible deadlock that lockdep reports as an IRQ lock
inversion:

  CPU0                              CPU1
  ----                              ----
  lock(&amp;chip-&gt;lock)                 lock(irq_desc-&gt;lock)
  &lt;GPIO interrupt&gt;                  lock(&amp;chip-&gt;lock)
    lock(irq_desc-&gt;lock)

If a GPIO interrupt arrives on CPU0 while it holds the chip lock during
a direction change, the interrupt handler spins on the descriptor lock
that CPU1 holds, while CPU1 spins on the chip lock held by CPU0.

This was seen during probe of pwr-mlxbf. acpi_dev_gpio_irq_get() sets
the pin to input through mlxbf2_gpio_direction_input(), and then
irq_set_irq_type() runs with the descriptor lock held.

Use the irqsave variant for the chip lock in mlxbf2_gpio_lock_acquire()
and its release counterpart, and pass the saved flags from
mlxbf2_gpio_direction_input() and mlxbf2_gpio_direction_output(). This
matches the IRQ callbacks, so interrupts stay disabled for the whole
ModeX update.

Fixes: 2b725265cb08 ("gpio: mlxbf2: Introduce IRQ support")
Cc: stable@vger.kernel.org
Signed-off-by: David Thompson &lt;davthompson@nvidia.com&gt;
Link: https://patch.msgid.link/20261113184444.3431-1-davthompson@nvidia.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: virtio: compute the line names size in a size_t</title>
<updated>2026-11-17T08:27:51+00:00</updated>
<author>
<name>Lianjie Wang</name>
<email>lian@is.s.u-tokyo.ac.jp</email>
</author>
<published>2026-11-04T19:56:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9e3032dc4d92e6214ae687b4c474de9270ce74a2'/>
<id>9e3032dc4d92e6214ae687b4c474de9270ce74a2</id>
<content type='text'>
virtio_gpio_get_names() computes the size of the GET_LINE_NAMES response
as sizeof(*res) + gpio_names_size in an int, where gpio_names_size is a
u32 from the config space. A gpio_names_size of 0xffffffff makes the
size 0, devm_kzalloc() returns ZERO_SIZE_PTR, and reading the status
byte of the response through it oopses:

  Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI
  KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
  RIP: 0010:_virtio_gpio_req+0x2b8/0x550
  Call Trace:
   virtio_gpio_probe+0xc2a/0xfc0
   virtio_dev_probe+0xa7a/0xc50

Compute the size with struct_size() into a size_t.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang &lt;lian@is.s.u-tokyo.ac.jp&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Link: https://patch.msgid.link/20261104195632.1702765-2-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
virtio_gpio_get_names() computes the size of the GET_LINE_NAMES response
as sizeof(*res) + gpio_names_size in an int, where gpio_names_size is a
u32 from the config space. A gpio_names_size of 0xffffffff makes the
size 0, devm_kzalloc() returns ZERO_SIZE_PTR, and reading the status
byte of the response through it oopses:

  Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] SMP KASAN PTI
  KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
  RIP: 0010:_virtio_gpio_req+0x2b8/0x550
  Call Trace:
   virtio_gpio_probe+0xc2a/0xfc0
   virtio_dev_probe+0xa7a/0xc50

Compute the size with struct_size() into a size_t.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang &lt;lian@is.s.u-tokyo.ac.jp&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Link: https://patch.msgid.link/20261104195632.1702765-2-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: virtio: bound the line names block by its configured size</title>
<updated>2026-11-17T08:27:43+00:00</updated>
<author>
<name>Lianjie Wang</name>
<email>lian@is.s.u-tokyo.ac.jp</email>
</author>
<published>2026-11-04T19:56:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=74aee8e06277df39ec10ed043bae0ed5b7a83864'/>
<id>74aee8e06277df39ec10ed043bae0ed5b7a83864</id>
<content type='text'>
virtio_gpio_get_names() walks the line names that the device returns in
a block of gpio_names_size bytes, which the driver ends with a NUL, and
checks each name only after stepping past it. If the block holds fewer
than ngpio names, the walk reaches the end of the block after the last
name, and the next iteration starts strlen() at the byte after the
allocation. With a block that holds one name for four lines, KASAN
reports:

  BUG: KASAN: slab-out-of-bounds in strlen+0x57/0x70
  Read of size 1 at addr ffff8880026687c0 by task swapper/0/1
  Call Trace:
   strlen+0x57/0x70
   virtio_gpio_probe+0xcb4/0xfc0
   virtio_dev_probe+0xa7a/0xc50
  Allocated by task 1:
   devm_kmalloc+0x6e/0x280
   virtio_gpio_probe+0xc06/0xfc0
  The buggy address is located 0 bytes to the right of
   allocated 64-byte region [ffff888002668780, ffff8880026687c0)

Check that a name starts inside the block before reading it.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang &lt;lian@is.s.u-tokyo.ac.jp&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Link: https://patch.msgid.link/20261104195632.1702765-1-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
virtio_gpio_get_names() walks the line names that the device returns in
a block of gpio_names_size bytes, which the driver ends with a NUL, and
checks each name only after stepping past it. If the block holds fewer
than ngpio names, the walk reaches the end of the block after the last
name, and the next iteration starts strlen() at the byte after the
allocation. With a block that holds one name for four lines, KASAN
reports:

  BUG: KASAN: slab-out-of-bounds in strlen+0x57/0x70
  Read of size 1 at addr ffff8880026687c0 by task swapper/0/1
  Call Trace:
   strlen+0x57/0x70
   virtio_gpio_probe+0xcb4/0xfc0
   virtio_dev_probe+0xa7a/0xc50
  Allocated by task 1:
   devm_kmalloc+0x6e/0x280
   virtio_gpio_probe+0xc06/0xfc0
  The buggy address is located 0 bytes to the right of
   allocated 64-byte region [ffff888002668780, ffff8880026687c0)

Check that a name starts inside the block before reading it.

Fixes: 3a29355a22c0 ("gpio: Add virtio-gpio driver")
Cc: stable@vger.kernel.org
Signed-off-by: Lianjie Wang &lt;lian@is.s.u-tokyo.ac.jp&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Link: https://patch.msgid.link/20261104195632.1702765-1-lian@is.s.u-tokyo.ac.jp
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'v7.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into gpio/for-current</title>
<updated>2026-11-16T10:58:10+00:00</updated>
<author>
<name>Bartosz Golaszewski</name>
<email>bartosz.golaszewski@oss.qualcomm.com</email>
</author>
<published>2026-11-16T10:58:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3e68810e7c109ae4cc23541f36a1a9fc8ed65700'/>
<id>3e68810e7c109ae4cc23541f36a1a9fc8ed65700</id>
<content type='text'>
Linux 7.4-rc3
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Linux 7.4-rc3
</pre>
</div>
</content>
</entry>
<entry>
<title>gpio: cdev: don't overwrite the whole flags field when configuring lines</title>
<updated>2026-11-13T10:32:31+00:00</updated>
<author>
<name>Bartosz Golaszewski</name>
<email>bartosz.golaszewski@oss.qualcomm.com</email>
</author>
<published>2026-11-10T13:47:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fa8bc4aa06674e78a4ee702966419aa4fdd8dc94'/>
<id>fa8bc4aa06674e78a4ee702966419aa4fdd8dc94</id>
<content type='text'>
linehandle_flags_to_desc_flags() and
gpio_v2_line_config_flags_to_desc_flags() read the flags word with
READ_ONCE(), modify the local copy and write it back with WRITE_ONCE().

The per-request config_mutex does not exclude sysfs, the irq core or
drivers touching the same descriptor, so bits they set or clear
concurrently can be lost.

Build the mask of bits owned by the line configuration and their new
values locally and apply them with gpiod_update_flags(). The whole
group changes in a single atomic step.

While at it: rename the functions whose semantics changed from
"conversion" to "flags update" accordingly.

Cc: stable@vger.kernel.org
Fixes: b7adfb6076ff ("gpio: cdev: update flags at once when reconfiguring from user-space")
Reviewed-by: Kent Gibson &lt;warthog618@gmail.com&gt;
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-5-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
linehandle_flags_to_desc_flags() and
gpio_v2_line_config_flags_to_desc_flags() read the flags word with
READ_ONCE(), modify the local copy and write it back with WRITE_ONCE().

The per-request config_mutex does not exclude sysfs, the irq core or
drivers touching the same descriptor, so bits they set or clear
concurrently can be lost.

Build the mask of bits owned by the line configuration and their new
values locally and apply them with gpiod_update_flags(). The whole
group changes in a single atomic step.

While at it: rename the functions whose semantics changed from
"conversion" to "flags update" accordingly.

Cc: stable@vger.kernel.org
Fixes: b7adfb6076ff ("gpio: cdev: update flags at once when reconfiguring from user-space")
Reviewed-by: Kent Gibson &lt;warthog618@gmail.com&gt;
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-5-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski &lt;bartosz.golaszewski@oss.qualcomm.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
