[PATCH] Add NULL check for OWT effect data alloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jianyue Wu <wujianyue000@xxxxxxxxx>

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@xxxxxxxxx>
---
 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





[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux