linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
To: Christian Herzig
	<christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	chris-jmrfutXsf6TiB9QmIjCX8w@public.gmane.org
Subject: Re: [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer
Date: Tue, 25 Aug 2009 12:00:40 +0200	[thread overview]
Message-ID: <20090825100040.GF2039@gundam.enneenne.com> (raw)
In-Reply-To: <1251192966-25724-1-git-send-email-christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org>

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

       reply	other threads:[~2009-08-25 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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   ` Rodolfo Giometti [this message]
     [not found]     ` <20090825100040.GF2039-h5F9bMWSfx92wUeKyQHPq0EOCMrvLtNR@public.gmane.org>
2009-08-25 11:00       ` [PATCH 1/6] i2c pca954x: catch dereferencing from NULL-pointer chris-jmrfutXsf6TiB9QmIjCX8w

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090825100040.GF2039@gundam.enneenne.com \
    --to=giometti-avvdyk/kqijwk0htik3j/w@public.gmane.org \
    --cc=chris-jmrfutXsf6TiB9QmIjCX8w@public.gmane.org \
    --cc=christian.herzig-SkAbAL50j+5BDgjK7y7TUQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).