memstick: core: fix device_register() error handling

If device_register() fails then call put_device().  See comment to
device_register.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Vasiliy Kulikov 2011-01-12 17:01:00 -08:00 committed by Linus Torvalds
parent 563558b2c7
commit 0193383a58
1 changed files with 1 additions and 0 deletions

View File

@ -465,6 +465,7 @@ static void memstick_check(struct work_struct *work)
if (!host->card) {
host->card = card;
if (device_register(&card->dev)) {
put_device(&card->dev);
kfree(host->card);
host->card = NULL;
}