Search Linux Wireless

Re: [PATCH] wl18xx: Handle kfree() in better way when kzalloc fails

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

 



On Fri, Oct 7, 2016 at 12:36 PM, Johannes Berg
<johannes@xxxxxxxxxxxxxxxx> wrote:
>
> On Fri, 2016-10-07 at 12:19 +0530, Souptick Joarder wrote:
> > This patch is added to handle kfree and return error in a better way
>
> What's "better" about this?
>
> kfree(NULL) is perfectly valid, adding another label makes the code
> harder to read,

I agree with you.

when kzalloc(sizeof(*cmd), GFP_KERNEL) fails, try to avoid extra
kfree(cmd_channel) function call,
cause anyway it will call kfree with NULL.

I thought from that point of view.

>
> > -     struct wl18xx_cmd_scan_params *cmd;
> > +     struct wl18xx_cmd_scan_params *cmd = NULL;
>
> that new initialization is actually *completely* pointless since it's
> overwritten immediately here:
>
> >       struct wlcore_scan_channels *cmd_channels = NULL;
> >       int ret;
> >
> >       cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
> >       if (!cmd) {
> > -             ret = -ENOMEM;
> > -             goto out;
> > +             return -ENOMEM;
> >       }
> >
> ...
>
> what gives?
>

> johannes

Ok, I will drop this patch.

-Souptick



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux