diff options
author | Daniel Drake <dsd@laptop.org> | 2009-12-17 18:27:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-17 18:45:31 -0500 |
commit | 3d10a1ba0d37c8f5fd5afcdda00613fbb8a90bf5 (patch) | |
tree | 2ece821a975a989e3932a9a71ed4353b1edb32f7 /drivers/mmc/core | |
parent | f6151dfea21496d43dbaba32cfcd9c9f404769bc (diff) |
sdio: fix reference counting in sdio_remove_func()
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 <dsd@laptop.org>
Reviewed-by: Matt Fleming <matt@console-pimps.org>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/mmc/core')
-rw-r--r-- | drivers/mmc/core/sdio_bus.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index d37464e296a..9e060c87e64 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) | |||
248 | /* | 248 | /* |
249 | * Unregister a SDIO function with the driver model, and | 249 | * Unregister a SDIO function with the driver model, and |
250 | * (eventually) free it. | 250 | * (eventually) free it. |
251 | * This function can be called through error paths where sdio_add_func() was | ||
252 | * never executed (because a failure occurred at an earlier point). | ||
251 | */ | 253 | */ |
252 | void sdio_remove_func(struct sdio_func *func) | 254 | void sdio_remove_func(struct sdio_func *func) |
253 | { | 255 | { |
254 | if (sdio_func_present(func)) | 256 | if (!sdio_func_present(func)) |
255 | device_del(&func->dev); | 257 | return; |
256 | 258 | ||
259 | device_del(&func->dev); | ||
257 | put_device(&func->dev); | 260 | put_device(&func->dev); |
258 | } | 261 | } |
259 | 262 | ||