* [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config
@ 2024-12-03 14:14 Haoyu Li
2024-12-04 2:35 ` kernel test robot
2024-12-05 12:10 ` Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Haoyu Li @ 2024-12-03 14:14 UTC (permalink / raw)
To: Wentong Wu, Sakari Ailus, Linus Walleij, Bartosz Golaszewski,
Kees Cook, Gustavo A . R . Silva, Greg Kroah-Hartman, linux-gpio,
linux-kernel, linux-hardening
Cc: stable, Haoyu Li
With the new __counted_by annocation in ljca_gpio_packet, the "num"
struct member must be set before accessing the "item" array. Failing to
do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS
and CONFIG_FORTIFY_SOURCE.
Fixes: 1034cc423f1b ("gpio: update Intel LJCA USB GPIO driver")
Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
---
drivers/gpio/gpio-ljca.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-ljca.c b/drivers/gpio/gpio-ljca.c
index 503d2441c58f..817ecb12d550 100644
--- a/drivers/gpio/gpio-ljca.c
+++ b/drivers/gpio/gpio-ljca.c
@@ -82,9 +82,9 @@ static int ljca_gpio_config(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id,
int ret;
mutex_lock(&ljca_gpio->trans_lock);
+ packet->num = 1;
packet->item[0].index = gpio_id;
packet->item[0].value = config | ljca_gpio->connect_mode[gpio_id];
- packet->num = 1;
ret = ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_CONFIG, (u8 *)packet,
struct_size(packet, item, packet->num), NULL, 0);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config
2024-12-03 14:14 [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config Haoyu Li
@ 2024-12-04 2:35 ` kernel test robot
2024-12-05 12:10 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2024-12-04 2:35 UTC (permalink / raw)
To: Haoyu Li; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config
Link: https://lore.kernel.org/stable/20241203141451.342316-1-lihaoyu499%40gmail.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config
2024-12-03 14:14 [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config Haoyu Li
2024-12-04 2:35 ` kernel test robot
@ 2024-12-05 12:10 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2024-12-05 12:10 UTC (permalink / raw)
To: Wentong Wu, Sakari Ailus, Linus Walleij, Bartosz Golaszewski,
Kees Cook, Gustavo A . R . Silva, Greg Kroah-Hartman, linux-gpio,
linux-kernel, linux-hardening, Haoyu Li
Cc: Bartosz Golaszewski, stable
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Tue, 03 Dec 2024 22:14:51 +0800, Haoyu Li wrote:
> With the new __counted_by annocation in ljca_gpio_packet, the "num"
> struct member must be set before accessing the "item" array. Failing to
> do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS
> and CONFIG_FORTIFY_SOURCE.
>
> Fixes: 1034cc423f1b ("gpio: update Intel LJCA USB GPIO driver")
>
> [...]
Applied, thanks!
[1/1] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config
commit: 963deccd17d4e538a8bafb1617803746efe910ef
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-05 12:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 14:14 [PATCH] drivers: gpio: gpio-ljca: Initialize num before accessing item in ljca_gpio_config Haoyu Li
2024-12-04 2:35 ` kernel test robot
2024-12-05 12:10 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox