lkml.org 
[lkml]   [2017]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
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 <christophe.jaillet@wanadoo.fr>
> ---
> 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
times...

thnaks,

greg k-h

\
 
 \ /
  Last update: 2017-08-31 18:57    [W:0.079 / U:5.808 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site