diff mbox

[fix?] bcma: use (get|put)_device when probing/removing device driver

Message ID 20170128133122.12360-1-zajec5@gmail.com (mailing list archive)
State Accepted
Commit a971df0b9d04674e325346c17de9a895425ca5e1
Delegated to: Kalle Valo
Headers show

Commit Message

Rafał Miłecki Jan. 28, 2017, 1:31 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This allows tracking device state and e.g. makes devm work as expected.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Cc: Stable <stable@vger.kernel.org>
---
Kalle: this issue is in bcma since /ever/, so I'm Cc-ing stable without
pointing any version.

If someone reviewes (you or anyone) you may consider taking it as 3.10 fix.
Can someone confirm this patch is OK?
---
 drivers/bcma/main.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kalle Valo Jan. 31, 2017, 7:15 a.m. UTC | #1
Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This allows tracking device state and e.g. makes devm work as expected.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Cc: Stable <stable@vger.kernel.org>

At this stage of the cycle I think 4.11 is more approriate for this fix.
Kalle Valo Jan. 31, 2017, 7:27 a.m. UTC | #2
Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This allows tracking device state and e.g. makes devm work as expected.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> Cc: Stable <stable@vger.kernel.org>

Patch applied to wireless-drivers-next.git, thanks.

a971df0b9d04 bcma: use (get|put)_device when probing/removing device driver
diff mbox

Patch

diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 2c1798e38abd..38688236b3cd 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -633,8 +633,11 @@  static int bcma_device_probe(struct device *dev)
 					       drv);
 	int err = 0;
 
+	get_device(dev);
 	if (adrv->probe)
 		err = adrv->probe(core);
+	if (err)
+		put_device(dev);
 
 	return err;
 }
@@ -647,6 +650,7 @@  static int bcma_device_remove(struct device *dev)
 
 	if (adrv->remove)
 		adrv->remove(core);
+	put_device(dev);
 
 	return 0;
 }