[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4820997E.1070305@openvz.org>
Date: Tue, 06 May 2008 21:46:38 +0400
From: Pavel Emelyanov <xemul@...nvz.org>
To: Ingo Oeser <netdev@...eo.de>
CC: Johannes Berg <johannes@...solutions.net>,
"John W. Linville" <linville@...driver.com>,
David Miller <davem@...emloft.net>,
linux-wireless@...r.kernel.org,
Linux Netdev List <netdev@...r.kernel.org>
Subject: Re: [PATCH 1/4][MAC80211]: Fix GFP_KERNEL allocation under read lock.
Ingo Oeser wrote:
> Hi Pavel,
>
> regarding:
>
> [PATCH 1/4][MAC80211]: Fix GFP_KERNEL allocation under read lock
> [PATCH 2/4][MAC80211]: Fix not checked kmalloc() result
>
> Pavel Emelyanov schrieb:
>> The mesh_path_add() read-locks the pathtbl_resize_lock and calls
>> kmalloc with GFP_KERNEL mask.
>>
>> Fix it and move the endadd2 label lower. It should be _before_ the
>> if() beyond, but it makes no sense for it being there, so I move it
>> right after this if().
>
> What about doing both allocations in succession to local variables,
> share the failure path if an error occours an kfree them unconditionally
> like this?
I do not quite like doing so. Since this relies on fact that kfree bears
NULL pointers. But if we ever switch from kmalloc to kmem_cache_alloc,
this will result in an oops.
And as far as sharing the error paths are concerned, I make such thing
in the 4th patch in a more classical manner.
> new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
> new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL);
> if (!new_node || !new_mpath) {
> kfree(new_mpath);
> kfree(new_node);
> atomic_dec(&sdata->u.sta.mpaths);
> err = -ENOMEM;
> goto endadd2;
> }
> ...
> read_lock(...);
> ...
>
> Rationale: Allocations are always likely to fail/succeed in close succession.
>
>
> Best Regards
>
> Ingo Oeser
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists