Re: [PATCH] efivars: prevent oops on unload when efi is not enabled

From: Mike Waychison
Date: Fri May 06 2011 - 16:09:49 EST


On Fri, May 6, 2011 at 3:04 PM, Matt Domsch <Matt_Domsch@xxxxxxxx> wrote:
> On Fri, May 06, 2011 at 02:57:02PM -0500, Randy Dunlap wrote:
>> From: Randy Dunlap <randy.dunlap@xxxxxxxxxx>
>>
>> unregister_efivars() should check for efi_enabled and not undo
>> allocations when efi is not enabled.  Otherwise there is an Oops
>> during module unload:
>
> Thanks Randy.
>
> I'm not sure why the driver is still loaded at all if efi_enabled==0.
>
> static int __init
> efivars_init(void)
> {
> ...
>        if (!efi_enabled)
>                return 0;
>
>
>
> That return 0 should be return -ENODEV I think.  Mike?

Ya, I changed efivars so that others could still use the
register_efivars/unregister_efivars interfaces when !efi_enabled.
They are used by the drivers/firmware/google/gsmi.c driver currently
pending in linux-next.

I think the right approach in this case would be to do

if (efi_enabled) {
unregister_efivars(&__efivars);
kobject_put(efi_kobj);
}

in efivars_exit().

>
> Thanks,
> Matt
>
> --
> Matt Domsch
> Technology Strategist
> Dell | Office of the CTO
>
--
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/