lkml.org 
[lkml]   [2023]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] pinctrl:sunplus: Add check for kmalloc
Date
> > Fix Smatch static checker warning:
> > potential null dereference 'configs'. (kmalloc returns null)
>
> ...
>
> > configs = kmalloc(sizeof(*configs), GFP_KERNEL);
> > + if (!configs)
>
> > + return -ENOMEM;
>
> "Fixing" by adding a memory leak is not probably a good approach.

Do you mean I need to free all memory which are allocated in this subroutine before
return -ENOMEM?


> ...
>
> > configs = kmalloc(sizeof(*configs), GFP_KERNEL);
> > + if (!configs)
> > + return -ENOMEM;
>
> Ditto.
>
> ...
>
> It might be that I'm mistaken. In this case please add an explanation why in the commit
> message.
>
> --
> With Best Regards,
> Andy Shevchenko
>


Best regards,
Wells Lu
\
 
 \ /
  Last update: 2023-05-23 20:21    [W:0.870 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site