Re: [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer

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

 



On Tue, Aug 25, 2009 at 11:36:06AM +0200, Christian Herzig wrote:
> pdata can be NULL, so pdata->modes[i] will crashes the kernel.
> 
> Signed-off-by: Christian Herzig <christian.herzig@xxxxxxxxxxx>
> ---
>  drivers/i2c/muxes/pca954x.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> index b12e6b7..59d3917 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -259,10 +259,12 @@ static int pca954x_probe(struct i2c_client *client,
>  			goto virt_reg_failed;
>  		}
>  
> -		data->deselect_on_exit = pdata ?
> +		if (pdata) {
> +			data->deselect_on_exit = pdata ?
>  				pdata->modes[i].deselect_on_exit : 0;
> -		data->is_chan_connected = pdata ?
> +			data->is_chan_connected = pdata ?
>  				pdata->modes[i].is_chan_connected : NULL;
> +		}
>  	}
>  
>  	dev_info(&client->dev, "registered %d virtual busses for I2C %s %s\n",
> -- 
> 1.6.0.1

If pdata is NULL then the condition is false and the CPU should jump
to the false branch and returning 0 or NULL. Did you really get error
here?

Ciao,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail: giometti@xxxxxxxxxxxx
Linux Device Driver                          giometti@xxxxxxxx
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux