lkml.org 
[lkml]   [2021]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] media: usb: dvb-usb-v2: check the return value of kstrdup()
Date
On Tue, Dec 14, 2021 11:03 PM +0800, Mauro Carvalho Chehab wrote:
>> + if (!devname)
>> + dev_err(&d->udev->dev, "%s: kstrdup() failed\n", KBUILD_MODNAME);
>> +
> Don't use KBUILD_MODNAME, as dev_err will already add the driver/device's
> name.

Here I know I need to change it to: dev_err(&d->udev->dev, "kstrdup() failed\n");

>> - pr_info("%s: '%s:%s' successfully deinitialized and disconnected\n",
>> - KBUILD_MODNAME, drvname, devname);
>
> Better to use:
> dev_dbg(&d->udev->dev, "successfully deinitialized and disconnected\n");
>
>> - kfree(devname);
> No need to place kfree() inside an if, as kfree(NULL) is safe.

Here I know I need to put kfree() at the end of this function.
However, if I replace the original pr_info(...) with:
> dev_dbg(&d->udev->dev, "successfully deinitialized and disconnected\n");
Then devname and drvname seems can be all removed, as they are useless
in dvb_usbv2_disconnect() anymore. I am not sure if I understand correctly.
If so, I will just remove them and change pr_info() -> dev_dbg() in next
version.
\
 
 \ /
  Last update: 2021-12-14 16:52    [W:0.033 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site