[PATCH] rspiusb: Check usb_buffer_map_sg() retval

Jiri Slaby jirislaby at gmail.com
Sat Aug 22 17:09:01 UTC 2009


On 08/22/2009 06:56 PM, Roel Kluin wrote:
> @@ -687,9 +688,13 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
>  	} else {
>  		pdx->sgl[frameInfo][0].length = count;
>  	}
> -	pdx->sgEntries[frameInfo] =
> -	    usb_buffer_map_sg(pdx->udev, epAddr, pdx->sgl[frameInfo],
> -			      pdx->maplist_numPagesMapped[frameInfo]);
> +	ret = usb_buffer_map_sg(pdx->udev, epAddr, pdx->sgl[frameInfo],
> +			pdx->maplist_numPagesMapped[frameInfo]);
> +	if (ret < 0)
> +		return -EINVAL;
> +
> +	pdx->sgEntries[frameInfo] = ret;
> +
>  	dbg("number of sgEntries = %d", pdx->sgEntries[frameInfo]);
>  	pdx->userBufMapped = 1;
>  	vfree(maplist_p);

Except you should vfree first...



More information about the devel mailing list