Re: [PATCH] net: hso: register netdev later to avoid a race condition

From: Johan Hovold
Date: Fri Apr 28 2017 - 15:00:40 EST


On Fri, Apr 28, 2017 at 07:36:29PM +0200, Andreas Kemnade wrote:
> On Thu, 27 Apr 2017 10:44:01 +0200
> Johan Hovold <johan@xxxxxxxxxx> wrote:
>
> > On Wed, Apr 26, 2017 at 07:26:40PM +0200, Andreas Kemnade wrote:
> > > If the netdev is accessed before the urbs are initialized,
> > > there will be NULL pointer dereferences. That is avoided by
> > > registering it when it is fully initialized.
> >
> > > Reported-by: H. Nikolaus Schaller <hns@xxxxxxxxxxxxx>
> > > Signed-off-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>

> > This all looks good, but you should consider cleaning up the error
> > handling of this function as a follow-up as we should not be
> > deregistering netdevs that have never been registered (e.g. if a
> > required endpoint is missing or if registration fails for some reason).
> >
> > But just to be clear, this problem existed also before this change.
> >
> Just to check wether I am understanding this correctly. In your opinion
> this patch is good for now. And later when it is applied, there should
> be an additional error handling cleanup patch.

Exactly; your patch is fine as is and the error-handling issue can be
fixed separately.

Thanks,
Johan