Skip to content

Commit e4dbfa6

Browse files
learjet5gregkh
authored andcommitted
gpio: ljca: Initialize num before accessing item in ljca_gpio_config
commit 3396995 upstream. 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: 1034cc4 ("gpio: update Intel LJCA USB GPIO driver") Cc: [email protected] Signed-off-by: Haoyu Li <[email protected]> Link: https://lore.kernel.org/stable/20241203141451.342316-1-lihaoyu499%40gmail.com Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e9bce60 commit e4dbfa6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpio-ljca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ static int ljca_gpio_config(struct ljca_gpio_dev *ljca_gpio, u8 gpio_id,
8282
int ret;
8383

8484
mutex_lock(&ljca_gpio->trans_lock);
85+
packet->num = 1;
8586
packet->item[0].index = gpio_id;
8687
packet->item[0].value = config | ljca_gpio->connect_mode[gpio_id];
87-
packet->num = 1;
8888

8989
ret = ljca_transfer(ljca_gpio->ljca, LJCA_GPIO_CONFIG, (u8 *)packet,
9090
struct_size(packet, item, packet->num), NULL, 0);

0 commit comments

Comments
 (0)