Re: Bug in BCMA: device_unregister causing "NULL pointer dereference at"

From: RafaÅ MiÅecki
Date: Thu Jul 21 2011 - 03:14:13 EST


W dniu 14 lipca 2011 16:45 uÅytkownik Francois Romieu
<romieu@xxxxxxxxxxxxx> napisaÅ:
> RafaÅ MiÅecki <zajec5@xxxxxxxxx> :
> [...]
>> Any tip, why does it happen?
>
> bcma_release_core_dev kfrees core while its list_head is still used ?
>
> May be something like this :
>
> diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
> index be52344..85fb3aa 100644
> --- a/drivers/bcma/main.c
> +++ b/drivers/bcma/main.c
> @@ -110,11 +110,14 @@ static int bcma_register_cores(struct bcma_bus *bus)
>
> Âstatic void bcma_unregister_cores(struct bcma_bus *bus)
> Â{
> - Â Â Â struct bcma_device *core;
> + Â Â Â struct bcma_device *core, *next;
>
> - Â Â Â list_for_each_entry(core, &bus->cores, list) {
> + Â Â Â list_for_each_entry_safe(core, next, &bus->cores, list) {
> + Â Â Â Â Â Â Â list_del(&core->list);
> Â Â Â Â Â Â Â Âif (core->dev_registered)
> Â Â Â Â Â Â Â Â Â Â Â Âdevice_unregister(&core->dev);
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â kfree(core);
> Â Â Â Â}
> Â}

Thanks for your help, but I'm afraid crash happens in totally
different place. Have you take a look at dmesg.log from my second
e-mail? NULL ptr exception happens in kobject_del.

--
RafaÅ
--
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/