]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
cosa: Add missing kfree in error path of cosa_write
authorWang Hai <wanghai38@huawei.com>
Tue, 10 Nov 2020 14:46:14 +0000 (22:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 18:20:28 +0000 (19:20 +0100)
[ Upstream commit 52755b66ddcef2e897778fac5656df18817b59ab ]

If memory allocation for 'kbuf' succeed, cosa_write() doesn't have a
corresponding kfree() in exception handling. Thus add kfree() for this
function implementation.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Acked-by: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
Link: https://lore.kernel.org/r/20201110144614.43194-1-wanghai38@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wan/cosa.c

index af539151d6638843e22e3238effee864ea307bbd..61428076f32e420f040c72a09f681e0768d03dac 100644 (file)
@@ -889,6 +889,7 @@ static ssize_t cosa_write(struct file *file,
                        chan->tx_status = 1;
                        spin_unlock_irqrestore(&cosa->lock, flags);
                        up(&chan->wsem);
+                       kfree(kbuf);
                        return -ERESTARTSYS;
                }
        }