linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer
       [not found] ` <1251192966-25724-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
@ 2009-08-25 10:00   ` Rodolfo Giometti
       [not found]     ` <20090825100040.GF2039-h5F9bMWSfx92wUeKyQHPq0EOCMrvLtNR@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Rodolfo Giometti @ 2009-08-25 10:00 UTC (permalink / raw)
  To: Christian Herzig
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, chris-jmrfutXsf6TiB9QmIjCX8w

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-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
> ---
>  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-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org
Linux Device Driver                          giometti-k2GhghHVRtY@public.gmane.org
Embedded Systems                     phone:  +39 349 2432127
UNIX programming                     skype:  rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer
       [not found]     ` <20090825100040.GF2039-h5F9bMWSfx92wUeKyQHPq0EOCMrvLtNR@public.gmane.org>
@ 2009-08-25 11:00       ` chris-jmrfutXsf6TiB9QmIjCX8w
  0 siblings, 0 replies; 2+ messages in thread
From: chris-jmrfutXsf6TiB9QmIjCX8w @ 2009-08-25 11:00 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA; +Cc: Christian Herzig

> 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?

Oh, I see! that patch becomes void! Thanks for your explanatory note.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-25 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1251192966-25724-1-git-send-email-christian.herzig@keymile.com>
     [not found] ` <1251192966-25724-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
2009-08-25 10:00   ` [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer Rodolfo Giometti
     [not found]     ` <20090825100040.GF2039-h5F9bMWSfx92wUeKyQHPq0EOCMrvLtNR@public.gmane.org>
2009-08-25 11:00       ` chris-jmrfutXsf6TiB9QmIjCX8w

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).