projects/linux·commit 3d10a1ba

sdio: fix reference counting in sdio_remove_func()

3d10a1ba · Daniel Drake <[email protected]> · 2009-12-17 15:27:17 -08:00

sdio_remove_func() needs to be more careful about reference counting.  It
can be called in error paths where sdio_add_func() has never been called
e.g.  mmc_attach_sdio error path --> mmc_sdio_remove --> sdio_remove_func

Signed-off-by: Daniel Drake <[email protected]>
Reviewed-by: Matt Fleming <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
3d10a1ba0d37c8f5fd5afcdda00613fbb8a90bf5
Parents
f6151dfe

Changes

1 files changed · +5 −2

FileStatusAddDelContent
drivers/mmc/core/sdio_bus.cmodified+5−2View file

drivers/mmc/core/sdio_bus.c

View file
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c
index d37464e..9e060c8 100644
--- a/drivers/mmc/core/sdio_bus.c
+++ b/drivers/mmc/core/sdio_bus.c
@@ -248,12 +248,15 @@ int sdio_add_func(struct sdio_func *func)
/*
* Unregister a SDIO function with the driver model, and
* (eventually) free it.
+ * This function can be called through error paths where sdio_add_func() was
+ * never executed (because a failure occurred at an earlier point).
*/
void sdio_remove_func(struct sdio_func *func)
{
- if (sdio_func_present(func))
- device_del(&func->dev);
+ if (!sdio_func_present(func))
+ return;
+ device_del(&func->dev);
put_device(&func->dev);
}