Commit 1c40cde6 authored by Wang Hai's avatar Wang Hai Committed by David S. Miller

arcnet: fix potential memory leak in com20020_probe()

In com20020_probe(), if com20020_config() fails, dev and info
will not be freed, which will lead to a memory leak.

This patch adds freeing dev and info after com20020_config()
fails to fix this bug.

Compile tested only.

Fixes: 15b99ac1 ("[PATCH] pcmcia: add return value to _config() functions")
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 178a4ff1
...@@ -113,6 +113,7 @@ static int com20020_probe(struct pcmcia_device *p_dev) ...@@ -113,6 +113,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
struct com20020_dev *info; struct com20020_dev *info;
struct net_device *dev; struct net_device *dev;
struct arcnet_local *lp; struct arcnet_local *lp;
int ret = -ENOMEM;
dev_dbg(&p_dev->dev, "com20020_attach()\n"); dev_dbg(&p_dev->dev, "com20020_attach()\n");
...@@ -142,12 +143,18 @@ static int com20020_probe(struct pcmcia_device *p_dev) ...@@ -142,12 +143,18 @@ static int com20020_probe(struct pcmcia_device *p_dev)
info->dev = dev; info->dev = dev;
p_dev->priv = info; p_dev->priv = info;
return com20020_config(p_dev); ret = com20020_config(p_dev);
if (ret)
goto fail_config;
return 0;
fail_config:
free_arcdev(dev);
fail_alloc_dev: fail_alloc_dev:
kfree(info); kfree(info);
fail_alloc_info: fail_alloc_info:
return -ENOMEM; return ret;
} /* com20020_attach */ } /* com20020_attach */
static void com20020_detach(struct pcmcia_device *link) static void com20020_detach(struct pcmcia_device *link)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment