Re: [PATCH 1/3] staging: slicoss: return -ENOMEM if kzalloc fail

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

 



On Wed, Oct 24, 2012 at 04:15:42AM -0400, devendra.aaru wrote:
> On Wed, Oct 24, 2012 at 3:39 AM, Denis Kirjanov <kirjanov@xxxxxxxxx> wrote:
> > On Wed, Oct 24, 2012 at 2:04 AM, Devendra Naga <devendra.aaru@xxxxxxxxx> wrote:
> >> --- a/drivers/staging/slicoss/slicoss.c
> >> +++ b/drivers/staging/slicoss/slicoss.c
> >> @@ -3667,6 +3667,8 @@ static u32 slic_card_locate(struct adapter *adapter)
> >>         if (!physcard) {
> >>                 /* no structure allocated for this physical card yet */
> >>                 physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
> >> +               if (!physcard)
> >> +                       return -ENOMEM;
> >
> > You have not released the card pointer allocated earlier.
> 
> if card_hostid is SLIC_HOSTID_DEFAULT,
> 
> the below patch will take care of it:
> 
> diff --git a/drivers/staging/slicoss/slicoss.c
> b/drivers/staging/slicoss/slicoss.c
> index f08f459..801ccb4 100644
> --- a/drivers/staging/slicoss/slicoss.c
> +++ b/drivers/staging/slicoss/slicoss.c
> @@ -3657,8 +3657,10 @@ static u32 slic_card_locate(struct adapter *adapter)
>         if (!physcard) {
>                 /* no structure allocated for this physical card yet */
>                 physcard = kzalloc(sizeof(struct physcard), GFP_ATOMIC);
> -               if (!physcard)
> +               if (!physcard) {
> +                       free(card);

You didn't try compiling this.  Never try sending a patch the same
day you write it.  It's not as if there is a massive rush.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux