[PATCH] staging: wlags49_h2: Replace kmalloc+memset by kzalloc and add error handling.

Dan Carpenter dan.carpenter at oracle.com
Fri Mar 23 10:40:29 UTC 2012


On Fri, Mar 23, 2012 at 03:27:10PM +0530, santosh prasad nayak wrote:
> On Fri, Mar 23, 2012 at 3:21 PM, Dan Carpenter <dan.carpenter at oracle.com> wrote:
> > On Fri, Mar 23, 2012 at 03:11:45PM +0530, santosh nayak wrote:
> >> -        dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
> >> -        memset( dev_wds, 0, sizeof( struct net_device ));
> >> +     dev_wds = kzalloc(sizeof(struct net_device), GFP_KERNEL);
> >> +     if (unlikely(!dev_wds)) {
> >> +             printk(KERN_ERR "%s: failed to alloc memory\n", __func__);
> >
> > Don't resend, but kmalloc() already prints out way more extensive
> > and useful error messages than this.  No need to print an error
> > message yourself normally.
> >
> 
> Do you mean in the following format ?
> 
> +       if (unlikely(!dev_wds)) {
> +               DBG_LEAVE(DbgInfo);
> +               return;
> +       }

No need to resend.  It's just for next time something to consider.

regards,
dan carpenter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/attachments/20120323/67aeea26/attachment.asc>


More information about the devel mailing list