diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2021-05-25 21:44:04 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-20 16:21:11 +0200 |
commit | 331f5923fce4f45b8170ccf06c529e8eb28f37bc (patch) | |
tree | be91f0e74aac1abe8b9bd9ab33a9fd6f46052745 | |
parent | a622c5ad9c73c7cce7d445586fb8734fca3ecc77 (diff) | |
download | linux-stable-331f5923fce4f45b8170ccf06c529e8eb28f37bc.tar.gz linux-stable-331f5923fce4f45b8170ccf06c529e8eb28f37bc.tar.bz2 linux-stable-331f5923fce4f45b8170ccf06c529e8eb28f37bc.zip |
tty: serial: 8250: serial_cs: Fix a memory leak in error handling path
[ Upstream commit fad92b11047a748c996ebd6cfb164a63814eeb2e ]
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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/dc25f96b7faebf42e60fe8d02963c941cf4d8124.1621971720.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/tty/serial/8250/serial_cs.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c index ba9731ace0e4..3747991024d5 100644 --- a/drivers/tty/serial/8250/serial_cs.c +++ b/drivers/tty/serial/8250/serial_cs.c @@ -305,6 +305,7 @@ static int serial_resume(struct pcmcia_device *link) static int serial_probe(struct pcmcia_device *link) { struct serial_info *info; + int ret; dev_dbg(&link->dev, "serial_attach()\n"); @@ -319,7 +320,15 @@ static int serial_probe(struct pcmcia_device *link) if (do_sound) 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) |