From: Vladimir Kondratiev Date: Mon, 14 Jul 2014 06:49:40 +0000 (+0300) Subject: wil6210: fix memory leak on error path in wil_write_file_rxon() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=359ee6275368c6fc8c6143f706e1b0075a244070;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git wil6210: fix memory leak on error path in wil_write_file_rxon() If copy_from_user() fails, buffer allocated for parameters would leak Signed-off-by: Vladimir Kondratiev Signed-off-by: John W. Linville --- diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index 7435b5a256ab..b6400680850a 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -448,8 +448,10 @@ static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf, char *kbuf = kmalloc(len + 1, GFP_KERNEL); if (!kbuf) return -ENOMEM; - if (copy_from_user(kbuf, buf, len)) + if (copy_from_user(kbuf, buf, len)) { + kfree(kbuf); return -EIO; + } kbuf[len] = '\0'; rc = kstrtol(kbuf, 0, &channel);