[PATCH v2 4/5] staging: rtl8188eu: fix potential leak in rtw_mp_SetRFPath()

Dan Carpenter dan.carpenter at oracle.com
Wed May 7 20:08:06 UTC 2014


On Wed, May 07, 2014 at 09:33:20PM +0200, Christian Engelmayer wrote:
> Function rtw_mp_SetRFPath() 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 1077714.
> 
> Signed-off-by: Christian Engelmayer <cengelma at gmx.at>
> ---
>  drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> index 8b1579b..ea5e1f8 100644
> --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
> @@ -7321,11 +7321,14 @@ static int rtw_mp_SetRFPath(struct net_device *dev,
>  	struct adapter *padapter = rtw_netdev_priv(dev);
>  	char	*input = kmalloc(wrqu->data.length, GFP_KERNEL);

You didn't introduce this so there is no need to resend but doing the
allocation in the declaration block is nasty style.  No one reads the
declaration block and it is a common cause of bugs.  For example, the
bug you are fixing here.  ;)

>  	u8 bMain = 1, bTurnoff = 1;
> +	int ret = 0;

regards,
dan carpenter




More information about the devel mailing list