Skip to content

Commit

Permalink
pcmcia: cs: fix possible hung task and memory leak pccardd()
Browse files Browse the repository at this point in the history
If device_register() returns error in pccardd(), it leads two issues:

1. The socket_released has never been completed, it will block
   pcmcia_unregister_socket(), because of waiting for completion
   of socket_released.
2. The device name allocated by dev_set_name() is leaked.

Fix this two issues by calling put_device() when device_register() fails.
socket_released can be completed in pcmcia_release_socket(), the name can
be freed in kobject_cleanup().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Yang Yingliang <[email protected]>
Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Yang Yingliang authored and Dominik Brodowski committed Sep 3, 2023
1 parent 2dde18c commit e3ea1b4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/pcmcia/cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ static int pccardd(void *__skt)
dev_warn(&skt->dev, "PCMCIA: unable to register socket\n");
skt->thread = NULL;
complete(&skt->thread_done);
put_device(&skt->dev);
return 0;
}
ret = pccard_sysfs_add_socket(&skt->dev);
Expand Down

0 comments on commit e3ea1b4

Please sign in to comment.