Commit 3dad0d1e authored by Christian Engelmayer's avatar Christian Engelmayer Committed by Greg Kroah-Hartman

staging: rtl8188eu: fix potential leak in rtw_mp_QueryDrv()

Function rtw_mp_QueryDrv() dynamically allocates a temporary buffer that
is not freed in all error paths. Use a centralized exit path and make sure
that all memory is freed correctly. Detected by Coverity - CID 1077713.
Signed-off-by: default avatarChristian Engelmayer <cengelma@gmx.at>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5d57f1e8
...@@ -7350,12 +7350,15 @@ static int rtw_mp_QueryDrv(struct net_device *dev, ...@@ -7350,12 +7350,15 @@ static int rtw_mp_QueryDrv(struct net_device *dev,
char *input = kmalloc(wrqu->data.length, GFP_KERNEL); char *input = kmalloc(wrqu->data.length, GFP_KERNEL);
u8 qAutoLoad = 1; u8 qAutoLoad = 1;
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
int ret = 0;
if (!input) if (!input)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) {
return -EFAULT; ret = -EFAULT;
goto exit;
}
DBG_88E("%s:iwpriv in =%s\n", __func__, input); DBG_88E("%s:iwpriv in =%s\n", __func__, input);
qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */
...@@ -7369,8 +7372,10 @@ static int rtw_mp_QueryDrv(struct net_device *dev, ...@@ -7369,8 +7372,10 @@ static int rtw_mp_QueryDrv(struct net_device *dev,
sprintf(extra, "ok"); sprintf(extra, "ok");
} }
wrqu->data.length = strlen(extra) + 1; wrqu->data.length = strlen(extra) + 1;
exit:
kfree(input); kfree(input);
return 0; return ret;
} }
static int rtw_mp_set(struct net_device *dev, static int rtw_mp_set(struct net_device *dev,
......
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