Skip to contentSkip to conversation

GPIO: gpio-generic: Remove kfree() from bgpio_remove call

PATCH In review Alexander Shiyan 2 participants 3 messages Apr 11, 2013 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GPIO: gpio-generic: Remove kfree() from bgpio_remove call

Memory for basic-mmio-gpio driver is allocated by resource managed function, so using kfree() call in bgpio_remove is wrong. This patch eliminates this kfree() call.

---
 drivers/gpio/gpio-generic.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpio/gpio-generic.c +1 -5
index 42d4706..d2196bf 100644
@@ -390,11 +390,7 @@ static int bgpio_setup_direction(struct bgpio_chip *bgc,
 
 int bgpio_remove(struct bgpio_chip *bgc)
 {
-	int err = gpiochip_remove(&bgc->gc);
-
-	kfree(bgc);
-
-	return err;
+	return gpiochip_remove(&bgc->gc);
 }
 EXPORT_SYMBOL_GPL(bgpio_remove);
 
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/1 GPIO: gpio-generic: Remove kfree() from bgpio_remove call

Quoted 5 lines · Alexander Shiyan

Memory for basic-mmio-gpio driver is allocated by resource managed function, so using kfree() call in bgpio_remove is wrong. This patch eliminates this kfree() call.

So I think the patch is correct but the commit message is wrong.

It is not certain at all that bgpio is resource managed, but the point of the patch should be that it's up to the driver using it to allocate and free its struct bgpio_chip, after calling this function.

A quick glance on the consumers gives at hand that this is the case for all consumers, so I took the liberty to update the commit message and apply it...

Yours,
Linus Walleij

#2 lore raw
In reply to Alexander Shiyan
Quoted 10 lines · Alexander Shiyan
Quoted 6 lines

Memory for basic-mmio-gpio driver is allocated by resource managed function, so using kfree() call in bgpio_remove is wrong. This patch eliminates this kfree() call.

So I think the patch is correct but the commit message is wrong.

Quoted 7 lines

It is not certain at all that bgpio is resource managed, but the point of the patch should be that it's up to the driver using it to allocate and free its struct bgpio_chip, after calling this function.

A quick glance on the consumers gives at hand that this is the case for all consumers, so I took the liberty to update the commit message and apply it...

OK, no problem.

---