[lkml]   [2017]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] driver core: bus: Fix a potential double free
On Tue, Aug 29, 2017 at 09:23:49PM +0200, Christophe JAILLET wrote:
> The .release function of driver_ktype is 'driver_release()'.
> This function frees the container_of this kobject.
> So, this memory must not be freed explicitly in the error handling path of
> 'bus_add_driver()'. Otherwise a double free will occur.

Oh, nice catch!

> Signed-off-by: Christophe JAILLET <>
> ---
> I have left the 'drv->p = NULL' even if it looks useless to me. It does not
> hurt. I have also left a comment to explain why we do not free 'drv->p'
> explicitly before zeroing this pointer.

We need that for when people do static structures. Like as is done for
drivers. Well, I think that's why we need it, can't really remember,
might as well be safe, the error handling paths here are crazy at


greg k-h

 \ /
  Last update: 2017-08-31 18:57    [W:0.048 / U:4.332 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site