Re: [PATCH] driver core: bus: Fix a potential double free

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

 



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@xxxxxxxxxx>
> ---
> 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
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux