summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunshui Jiang <jiangyunshui@kylinos.cn>2025-07-03 21:56:02 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-10 16:04:43 +0200
commitea20568895c1122f15b6fc9e8d02c6cbe22964f8 (patch)
tree428980e3649bf86537c8d3f985eb22a0e5136ee3
parente4d19e5d71b217940e33f2ef6c6962b7b68c5606 (diff)
Input: cs40l50-vibra - fix potential NULL dereference in cs40l50_upload_owt()
commit 4cf65845fdd09d711fc7546d60c9abe010956922 upstream. 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 <jiangyunshui@kylinos.cn> Fixes: c38fe1bb5d21 ("Input: cs40l50 - Add support for the CS40L50 haptic driver") Link: https://lore.kernel.org/r/20250704024010.2353841-1-jiangyunshui@kylinos.cn Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/input/misc/cs40l50-vibra.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/input/misc/cs40l50-vibra.c b/drivers/input/misc/cs40l50-vibra.c
index dce3b0ec8cf3..330f09123631 100644
--- a/drivers/input/misc/cs40l50-vibra.c
+++ b/drivers/input/misc/cs40l50-vibra.c
@@ -238,6 +238,8 @@ static int cs40l50_upload_owt(struct cs40l50_work *work_data)
header.data_words = len / sizeof(u32);
new_owt_effect_data = kmalloc(sizeof(header) + len, GFP_KERNEL);
+ if (!new_owt_effect_data)
+ return -ENOMEM;
memcpy(new_owt_effect_data, &header, sizeof(header));
memcpy(new_owt_effect_data + sizeof(header), work_data->custom_data, len);