[PATCH] staging: rtl8712: Fix freeing ERR_PTR

Julia Lawall julia.lawall at lip6.fr
Wed Apr 29 18:42:45 UTC 2015


On Wed, 29 Apr 2015, Gujulan Elango, Hari Prasath (H.) wrote:

> The return value of memdup_user is a pointer to errno.Freeing it will cause
> error.Hence set it to NULL before branching to free the pointer.smatch also
> raises the same warning.

Perhaps there is no point to jumping to the label if there is nothing to 
do there.

The code contains other strange things, like:

        if (status) {
                ret = -EFAULT;
		goto _r871x_mp_ioctl_hdl_exit;
        }
_r871x_mp_ioctl_hdl_exit:

Overall, it would be nice to see if the code could be reorganized so that 
there is only a goto if there is something to do to cleanup, so that 
return ret would only be executed in an error case, and so that the code 
would return 0 directly on success.

julia

> Signed-off-by: Hari Prasath Gujulan Elango <hgujulan at visteon.com>
> ---
>  drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> index 42fba3f..9d59be8 100644
> --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
> @@ -1915,6 +1915,7 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
>  	pparmbuf = memdup_user(p->pointer, len);
>  	if (IS_ERR(pparmbuf)) {
>  		ret = PTR_ERR(pparmbuf);
> +		pparmbuf = NULL;
>  		goto _r871x_mp_ioctl_hdl_exit;
>  	}
>  	poidparam = (struct mp_ioctl_param *)pparmbuf;
> -- 
> 1.9.1
> 


More information about the devel mailing list