public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] thermal: Fix potential NULL pointer accesses
Date: Thu, 09 Aug 2012 14:47:31 +0800	[thread overview]
Message-ID: <1344494851.1682.670.camel@rui.sh.intel.com> (raw)
In-Reply-To: <20120809062530.GA3779@roeck-us.net>

On 三, 2012-08-08 at 23:25 -0700, Guenter Roeck wrote:
> On Thu, Aug 09, 2012 at 08:44:55AM +0800, Zhang Rui wrote:
> > On 二, 2012-08-07 at 22:36 -0700, Guenter Roeck wrote:
> > > The type parameter in thermal_zone_device_register and
> > > thermal_cooling_device_register can be NULL, indicating that no sysfs attribute
> > > for the type should be created. Only call strlen() and strcpy() on type if it is
> > > not NULL.
> > > 
> > > This patch addresses Coverity #102180 and #102182: Dereference before null check
> > > 
> > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > Acked-by: Zhang Rui <rui.zhang@intel.com>
> > 
> How do we get this patch upstream ? I thought you'd take it through your tree.
> 
yep.

thanks,
rui
> Thanks,
> Guenter
> 
> > > ---
> > > Applies on top of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git (thermal).
> > > 
> > >  drivers/thermal/thermal_sys.c |    8 ++++----
> > >  1 file changed, 4 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> > > index 5be8728..e69f76d 100644
> > > --- a/drivers/thermal/thermal_sys.c
> > > +++ b/drivers/thermal/thermal_sys.c
> > > @@ -900,7 +900,7 @@ thermal_cooling_device_register(char *type, void *devdata,
> > >  	struct thermal_zone_device *pos;
> > >  	int result;
> > >  
> > > -	if (strlen(type) >= THERMAL_NAME_LENGTH)
> > > +	if (type && strlen(type) >= THERMAL_NAME_LENGTH)
> > >  		return ERR_PTR(-EINVAL);
> > >  
> > >  	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
> > > @@ -917,7 +917,7 @@ thermal_cooling_device_register(char *type, void *devdata,
> > >  		return ERR_PTR(result);
> > >  	}
> > >  
> > > -	strcpy(cdev->type, type);
> > > +	strcpy(cdev->type, type ? : "");
> > >  	mutex_init(&cdev->lock);
> > >  	INIT_LIST_HEAD(&cdev->thermal_instances);
> > >  	cdev->ops = ops;
> > > @@ -1343,7 +1343,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
> > >  	int count;
> > >  	int passive = 0;
> > >  
> > > -	if (strlen(type) >= THERMAL_NAME_LENGTH)
> > > +	if (type && strlen(type) >= THERMAL_NAME_LENGTH)
> > >  		return ERR_PTR(-EINVAL);
> > >  
> > >  	if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips)
> > > @@ -1365,7 +1365,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
> > >  		return ERR_PTR(result);
> > >  	}
> > >  
> > > -	strcpy(tz->type, type);
> > > +	strcpy(tz->type, type ? : "");
> > >  	tz->ops = ops;
> > >  	tz->device.class = &thermal_class;
> > >  	tz->devdata = devdata;
> > 
> > 
> > 



      reply	other threads:[~2012-08-09  6:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08  5:36 [PATCH] thermal: Fix potential NULL pointer accesses Guenter Roeck
2012-08-09  0:44 ` Zhang Rui
2012-08-09  6:25   ` Guenter Roeck
2012-08-09  6:47     ` Zhang Rui [this message]

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=1344494851.1682.670.camel@rui.sh.intel.com \
    --to=rui.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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