Re: [PATCH] media: sr030pc30: inconsistent NULL checking in sr030pc30_base_config()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 22, 2018 at 02:19:48PM +0300, Dan Carpenter wrote:
> If info->pdata is NULL then we would oops on the next line.  And we can
> flip the "ret" test around and give up if a failure has already occured.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> 
> diff --git a/drivers/media/i2c/sr030pc30.c b/drivers/media/i2c/sr030pc30.c
> index 2a4882cddc51..4ebd00198d34 100644
> --- a/drivers/media/i2c/sr030pc30.c
> +++ b/drivers/media/i2c/sr030pc30.c
> @@ -569,8 +569,8 @@ static int sr030pc30_base_config(struct v4l2_subdev *sd)
>  	if (!ret)
>  		ret = sr030pc30_pwr_ctrl(sd, false, false);
>  
> -	if (!ret && !info->pdata)
> -		return ret;
> +	if (ret || !info->pdata)
> +		return -EIO;

There seem to be a couple of other places checking pdata is not NULL,
including the driver's probe() function; doing the same here seems
redundant. Just checking ret and failing if it's non-zero should suffice:

if (ret)
	return ret;

Let me know if you'd like to respin; I can do that as well.

>  
>  	expmin = EXPOS_MIN_MS * info->pdata->clk_rate / (8 * 1000);
>  	expmax = EXPOS_MAX_MS * info->pdata->clk_rate / (8 * 1000);

-- 
Sakari Ailus
e-mail: sakari.ailus@xxxxxx



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux