Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: samsung-keypad - use struct_size() helper

When allocating memory for the keypad use struct_size() helper to be
protected from overflows.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240819045813.2154642-5-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+3 -3
+3 -3
drivers/input/keyboard/samsung-keypad.c
··· 318 318 struct resource *res; 319 319 struct input_dev *input_dev; 320 320 unsigned int row_shift; 321 - unsigned int keymap_size; 322 321 int error; 323 322 324 323 pdata = dev_get_platdata(&pdev->dev); ··· 344 345 pdata->cfg_gpio(pdata->rows, pdata->cols); 345 346 346 347 row_shift = get_count_order(pdata->cols); 347 - keymap_size = (pdata->rows << row_shift) * sizeof(keypad->keycodes[0]); 348 348 349 - keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad) + keymap_size, 349 + keypad = devm_kzalloc(&pdev->dev, 350 + struct_size(keypad, keycodes, 351 + pdata->rows << row_shift), 350 352 GFP_KERNEL); 351 353 if (!keypad) 352 354 return -ENOMEM;