[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250705005216.279-1-wujianyue000@gmail.com>
Date: Sat, 5 Jul 2025 08:52:16 +0800
From: jianywu <wujianyue000@...il.com>
To: jogletre@...nsource.cirrus.com,
fred.treven@...rus.com,
ben.bright@...rus.com,
dmitry.torokhov@...il.com
Cc: patches@...nsource.cirrus.com,
linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org,
Jianyue Wu <wujianyue000@...il.com>
Subject: [PATCH] Add NULL check for OWT effect data alloc
From: Jianyue Wu <wujianyue000@...il.com>
Add a NULL pointer check after kmalloc when allocating memory for OWT
effect data in cs40l50_upload_owt(). If the allocation fails, print an
error message and return -ENOMEM to prevent dereferencing a NULL
pointer.
Signed-off-by: Jianyue Wu <wujianyue000@...il.com>
---
drivers/input/misc/cs40l50-vibra.c | 2 ++
1 file changed, 2 insertions(+)
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);
--
2.48.1
Powered by blists - more mailing lists