All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Jiang Liu <jiang.liu@huawei.com>, Toshi Kani <toshi.kani@hp.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Yinghai Lu <yinghai@kernel.org>,
	linux-i2c@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] i2c-scmi: remove some bogus NULL checks
Date: Wed, 30 Oct 2013 16:39:33 +0000	[thread overview]
Message-ID: <20131030163933.GH26669@mwanda> (raw)
In-Reply-To: <20131030160257.GF3663@katana>

On Wed, Oct 30, 2013 at 05:02:58PM +0100, Wolfram Sang wrote:
> > --- a/drivers/i2c/busses/i2c-scmi.c
> > +++ b/drivers/i2c/busses/i2c-scmi.c
> > @@ -223,7 +223,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
> >  		goto out;
> >  
> >  	obj = pkg->package.elements + 1;
> > -	if (obj = NULL || obj->type != ACPI_TYPE_INTEGER) {
> > +	if (obj->type != ACPI_TYPE_INTEGER) {
> >  		ACPI_ERROR((AE_INFO, "Invalid argument type"));
> >  		result = -EIO;
> >  		goto out;

For obj to be 0 then pkg->package.elements must be -1.  If we're getting
a pointer of -1 then we're already screwed.  Also we already used
pkg->elements without the "+ 1" so we know that's not -1.

The reason for this patch was that some compilers assume pointer math
can't overflow and my checker was complaining.  We use
-fno-strict-overflow in the kernel, but it still seemed worth cleaning.

regards,
dan carpenter


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Wolfram Sang <wsa@the-dreams.de>
Cc: Jiang Liu <jiang.liu@huawei.com>, Toshi Kani <toshi.kani@hp.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Yinghai Lu <yinghai@kernel.org>,
	linux-i2c@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] i2c-scmi: remove some bogus NULL checks
Date: Wed, 30 Oct 2013 19:39:33 +0300	[thread overview]
Message-ID: <20131030163933.GH26669@mwanda> (raw)
In-Reply-To: <20131030160257.GF3663@katana>

On Wed, Oct 30, 2013 at 05:02:58PM +0100, Wolfram Sang wrote:
> > --- a/drivers/i2c/busses/i2c-scmi.c
> > +++ b/drivers/i2c/busses/i2c-scmi.c
> > @@ -223,7 +223,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
> >  		goto out;
> >  
> >  	obj = pkg->package.elements + 1;
> > -	if (obj == NULL || obj->type != ACPI_TYPE_INTEGER) {
> > +	if (obj->type != ACPI_TYPE_INTEGER) {
> >  		ACPI_ERROR((AE_INFO, "Invalid argument type"));
> >  		result = -EIO;
> >  		goto out;

For obj to be 0 then pkg->package.elements must be -1.  If we're getting
a pointer of -1 then we're already screwed.  Also we already used
pkg->elements without the "+ 1" so we know that's not -1.

The reason for this patch was that some compilers assume pointer math
can't overflow and my checker was complaining.  We use
-fno-strict-overflow in the kernel, but it still seemed worth cleaning.

regards,
dan carpenter


  reply	other threads:[~2013-10-30 16:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-19  8:46 [patch] i2c-scmi: remove some bogus NULL checks Dan Carpenter
2013-10-19  8:46 ` Dan Carpenter
     [not found] ` <20131019084622.GA9312-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2013-10-30 16:02   ` Wolfram Sang
2013-10-30 16:02     ` Wolfram Sang
2013-10-30 16:39     ` Dan Carpenter [this message]
2013-10-30 16:39       ` Dan Carpenter
2013-10-31 11:57 ` Wolfram Sang
2013-10-31 11:57   ` Wolfram Sang

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=20131030163933.GH26669@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=jiang.liu@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=toshi.kani@hp.com \
    --cc=wsa@the-dreams.de \
    --cc=yinghai@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.