Skip to content

Commit 402ab97

Browse files
Yang YingliangDominik Brodowski
authored andcommitted
pcmcia: ds: fix refcount leak in pcmcia_device_add()
As the comment of device_register() says, it should use put_device() to give up the reference in the error path. Then, insofar resources will be freed in pcmcia_release_dev(), the error path is no longer needed. In particular, this means that the (previously missing) dropping of the reference to &p_dev->function_config->ref is now handled by pcmcia_release_dev(). Fixes: 360b65b ("[PATCH] pcmcia: make config_t independent, add reference counting") Signed-off-by: Yang Yingliang <[email protected]> [[email protected]: simplification, commit message rewrite] Signed-off-by: Dominik Brodowski <[email protected]>
1 parent e3ea1b4 commit 402ab97

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/pcmcia/ds.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,14 @@ static struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,
573573

574574
pcmcia_device_query(p_dev);
575575

576-
if (device_register(&p_dev->dev))
577-
goto err_unreg;
576+
if (device_register(&p_dev->dev)) {
577+
mutex_lock(&s->ops_mutex);
578+
list_del(&p_dev->socket_device_list);
579+
s->device_count--;
580+
mutex_unlock(&s->ops_mutex);
581+
put_device(&p_dev->dev);
582+
return NULL;
583+
}
578584

579585
return p_dev;
580586

0 commit comments

Comments
 (0)