question about bgpio_remove (drivers/gpio/gpio-generic.c)

From: Julia Lawall
Date: Mon Dec 26 2011 - 12:10:35 EST


The function bgpio_remove in the file drivers/gpio/gpio-generic.c is defind as follows:

int bgpio_remove(struct bgpio_chip *bgc)
{
int err = gpiochip_remove(&bgc->gc);

kfree(bgc);

return err;
}
EXPORT_SYMBOL_GPL(bgpio_remove);

But bgc is allocated using devm_kzalloc, not kzalloc, and thus the kfree would seem to result in a dangling pointer. On the other hand, this function does not have access to the information required to call devm_kfree (&pdev->dev). Since the function is exported, should the interface be maintained, and the allocation of bgc converted to use kzalloc? Or should the interface be changed to add the required information. The callers in the kernel have the require information available.

thanks,
julia
--
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/