public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pcmcia: ds: fix refcount leak in pcmcia_device_add()
@ 2022-11-12  9:29 Yang Yingliang
  2022-11-12  9:29 ` [PATCH 2/2] pcmcia: ds: fix possible name leak in error path " Yang Yingliang
  2023-09-03 20:43 ` [PATCH 1/2] pcmcia: ds: fix refcount leak " Dominik Brodowski
  0 siblings, 2 replies; 4+ messages in thread
From: Yang Yingliang @ 2022-11-12  9:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux

If device_register() returns error, the refcount of function_config
need be put.

Fixes: 360b65b95bae ("[PATCH] pcmcia: make config_t independent, add reference counting")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/pcmcia/ds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index ace133b9f7d4..7d3258a1f8f8 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -574,10 +574,12 @@ static struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,
 	pcmcia_device_query(p_dev);
 
 	if (device_register(&p_dev->dev))
-		goto err_unreg;
+		goto err_put_ref;
 
 	return p_dev;
 
+ err_put_ref:
+	kref_put(&p_dev->function_config->ref, pcmcia_release_function);
  err_unreg:
 	mutex_lock(&s->ops_mutex);
 	list_del(&p_dev->socket_device_list);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-03 20:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-12  9:29 [PATCH 1/2] pcmcia: ds: fix refcount leak in pcmcia_device_add() Yang Yingliang
2022-11-12  9:29 ` [PATCH 2/2] pcmcia: ds: fix possible name leak in error path " Yang Yingliang
2023-09-03 20:45   ` Dominik Brodowski
2023-09-03 20:43 ` [PATCH 1/2] pcmcia: ds: fix refcount leak " Dominik Brodowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox