Re: [PATCHv3] leds-pca955x: Add proper error handling and fix bogusmemory handling

From: Sven Wegener
Date: Fri Aug 15 2008 - 15:36:54 EST


On Tue, 12 Aug 2008, Nate Case wrote:

> On Fri, 2008-08-08 at 09:27 +0200, Sven Wegener wrote:
> > Check the return value of led_classdev_register and unregister all
> > registered
> > devices, if registering one device fails. Also the dynamic memory
> > handling is
> > totally bogus. You can't allocate multiple chunks via kzalloc() and
> > expect them
> > to be in order later.
> >
> > Signed-off-by: Sven Wegener <sven.wegener@xxxxxxxxxxx>
>
> Acked-by: Nate Case <ncase@xxxxxxxxxxx>
>
> Thanks for the fix. It looks correct and I tested it on my board with a
> pca9553. I also confirmed that the original driver would in fact kernel
> Oops if compiled as a module and you rmmod it. With this fix, I can
> repeatedly insmod/rmmod successfully.

Thanks for testing!

Andrew, could you please update the patch in -mm with the one below. It
contains the below fixes, that were applied after you added it to -mm,
and is identical to the one Nate tested.

- Another 32 -> sizeof() conversion
- Move the unregister code to where we also free the memory on failure
- cancel_work_sync() when unregistering on failure