[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170831165708.GA26329@kroah.com>
Date: Thu, 31 Aug 2017 18:57:08 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [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@...adoo.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
Powered by blists - more mailing lists