Skip to content

Commit 4cf6584

Browse files
Yunshui Jiangdtor
authored andcommitted
Input: cs40l50-vibra - fix potential NULL dereference in cs40l50_upload_owt()
The cs40l50_upload_owt() function allocates memory via kmalloc() without checking for allocation failure, which could lead to a NULL pointer dereference. Return -ENOMEM in case allocation fails. Signed-off-by: Yunshui Jiang <[email protected]> Fixes: c38fe1b ("Input: cs40l50 - Add support for the CS40L50 haptic driver") Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent a106b6a commit 4cf6584

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/input/misc/cs40l50-vibra.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ static int cs40l50_upload_owt(struct cs40l50_work *work_data)
238238
header.data_words = len / sizeof(u32);
239239

240240
new_owt_effect_data = kmalloc(sizeof(header) + len, GFP_KERNEL);
241+
if (!new_owt_effect_data)
242+
return -ENOMEM;
241243

242244
memcpy(new_owt_effect_data, &header, sizeof(header));
243245
memcpy(new_owt_effect_data + sizeof(header), work_data->custom_data, len);

0 commit comments

Comments
 (0)