Re: [RESEND/PATCH] usb: gadget: goku_udc: Fix error path

From: Dan Carpenter
Date: Tue Oct 05 2010 - 12:54:32 EST


On Tue, Oct 05, 2010 at 06:20:05AM -0700, Greg KH wrote:
> On Mon, Oct 04, 2010 at 02:22:14PM +0200, Dan Carpenter wrote:
> > On Mon, Oct 04, 2010 at 01:29:00AM +0530, Rahul Ruikar wrote:
> > > call put_device() when device_register() fails.
> > >
> >
> > Sorry I didn't realize what you were trying to do here. This is not
> > correct at all.
> >
> > The right thing is to fix device_register() to call put_device() itself.
> > It's a bit involved, because all the callers will need to be audited but
> > someone is working on this I think.
>
> No, no one is working on this, and no, it's not possible to make this
> type of change to the driver core as discussed in the past due to the
> way struct device can be embedded within another structure.

Sorry I guess I lost track of the discussion. We could write a helper
macro which added the extra put device on failure? Isn't that the more
common case anyway? To be honest, I'm still not clear on when the extra
put_device() is appropriate and when it's not. :/ I'll look through
the archive.

Anyway, I would prefer a slightly different patch. The logic is easier
to follow if we keep the put_device() right next to the
device_register(). Also if we keep it in one function and we add a
helper macro later then coccinelle can rewrite it automatically.

I'll send my patch.

regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/