提交 1afa87fe 编写于 作者: C Christophe JAILLET 提交者: Yang Yingliang

tty: serial: 8250: serial_cs: Fix a memory leak in error handling path

stable inclusion
from linux-4.19.198
commit cddee5c287e26f6b2ba5c0ffdfc3a846f2f10461

--------------------------------

[ Upstream commit fad92b11 ]

In the probe function, if the final 'serial_config()' fails, 'info' is
leaking.

Add a resource handling path to free this memory.
Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/dc25f96b7faebf42e60fe8d02963c941cf4d8124.1621971720.git.christophe.jaillet@wanadoo.frSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d6cf97b5
...@@ -306,6 +306,7 @@ static int serial_resume(struct pcmcia_device *link) ...@@ -306,6 +306,7 @@ static int serial_resume(struct pcmcia_device *link)
static int serial_probe(struct pcmcia_device *link) static int serial_probe(struct pcmcia_device *link)
{ {
struct serial_info *info; struct serial_info *info;
int ret;
dev_dbg(&link->dev, "serial_attach()\n"); dev_dbg(&link->dev, "serial_attach()\n");
...@@ -320,7 +321,15 @@ static int serial_probe(struct pcmcia_device *link) ...@@ -320,7 +321,15 @@ static int serial_probe(struct pcmcia_device *link)
if (do_sound) if (do_sound)
link->config_flags |= CONF_ENABLE_SPKR; link->config_flags |= CONF_ENABLE_SPKR;
return serial_config(link); ret = serial_config(link);
if (ret)
goto free_info;
return 0;
free_info:
kfree(info);
return ret;
} }
static void serial_detach(struct pcmcia_device *link) static void serial_detach(struct pcmcia_device *link)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册