mfd: ab8500-debugfs: Use kasprintf
authorHimanshu Jha <himanshujha199640@gmail.com>
Wed, 7 Mar 2018 18:06:01 +0000 (23:36 +0530)
committerLee Jones <lee.jones@linaro.org>
Wed, 16 May 2018 08:21:48 +0000 (09:21 +0100)
Use kasprintf instead of combination of kmalloc and sprintf.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/ab8500-debugfs.c

index 8ba4107..831a1ce 100644 (file)
@@ -2519,11 +2519,10 @@ static ssize_t ab8500_subscribe_write(struct file *file,
        if (!dev_attr[irq_index])
                return -ENOMEM;
 
-       event_name[irq_index] = kmalloc(count, GFP_KERNEL);
+       event_name[irq_index] = kasprintf(GFP_KERNEL, "%lu", user_val);
        if (!event_name[irq_index])
                return -ENOMEM;
 
-       sprintf(event_name[irq_index], "%lu", user_val);
        dev_attr[irq_index]->show = show_irq;
        dev_attr[irq_index]->store = NULL;
        dev_attr[irq_index]->attr.name = event_name[irq_index];