[PATCH 1/3] staging: slicoss: return -ENOMEM if kzalloc fail
Denis Kirjanov
kirjanov at gmail.com
Wed Oct 24 16:30:34 UTC 2012
On 10/24/12, devendra.aaru <devendra.aaru at gmail.com> wrote:
> On Wed, Oct 24, 2012 at 3:39 AM, Denis Kirjanov <kirjanov at gmail.com> wrote:
>> On Wed, Oct 24, 2012 at 2:04 AM, Devendra Naga <devendra.aaru at gmail.com>
>> 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);
> return -ENOMEM;
> + }
>
> physcard->next = slic_global.phys_card;
> slic_global.phys_card = physcard;
>
> if you ok with this i will submit with signoff.
>
> thanks,
>
Reviewed-by: Denis Kirjanov <kirjanov at gmail.com>
--
Regards,
Denis
More information about the devel
mailing list