linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] device property: fix potential NULL pointer dereference
@ 2015-08-05 13:51 Andy Shevchenko
  2015-08-05 23:20 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2015-08-05 13:51 UTC (permalink / raw)
  To: Rafael J . Wysocki, Greg Kroah-Hartman, linux-kernel; +Cc: Andy Shevchenko

In device_add_property_set() we check pset parameter for a NULL, but few lines
later we do a pointer arithmetic without check that will crash kernel in the
set_secondary_fwnode().

Here we check if pset parameter is NULL and return immediately.

Fixes: 16ba08d5c9ec (device property: Introduce firmware node type for platform data)
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/property.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f3f6d16..37a7bb7 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -27,9 +27,10 @@
  */
 void device_add_property_set(struct device *dev, struct property_set *pset)
 {
-	if (pset)
-		pset->fwnode.type = FWNODE_PDATA;
+	if (!pset)
+		return;
 
+	pset->fwnode.type = FWNODE_PDATA;
 	set_secondary_fwnode(dev, &pset->fwnode);
 }
 EXPORT_SYMBOL_GPL(device_add_property_set);
-- 
2.4.6


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

* Re: [PATCH 1/1] device property: fix potential NULL pointer dereference
  2015-08-05 13:51 [PATCH 1/1] device property: fix potential NULL pointer dereference Andy Shevchenko
@ 2015-08-05 23:20 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2015-08-05 23:20 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Rafael J . Wysocki, Greg Kroah-Hartman, linux-kernel

On Wednesday, August 05, 2015 04:51:11 PM Andy Shevchenko wrote:
> In device_add_property_set() we check pset parameter for a NULL, but few lines
> later we do a pointer arithmetic without check that will crash kernel in the
> set_secondary_fwnode().
> 
> Here we check if pset parameter is NULL and return immediately.
> 
> Fixes: 16ba08d5c9ec (device property: Introduce firmware node type for platform data)
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I don't think there are any users of this in 4.2, so I'll queue it up for 4.3.

Thanks!


> ---
>  drivers/base/property.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/property.c b/drivers/base/property.c
> index f3f6d16..37a7bb7 100644
> --- a/drivers/base/property.c
> +++ b/drivers/base/property.c
> @@ -27,9 +27,10 @@
>   */
>  void device_add_property_set(struct device *dev, struct property_set *pset)
>  {
> -	if (pset)
> -		pset->fwnode.type = FWNODE_PDATA;
> +	if (!pset)
> +		return;
>  
> +	pset->fwnode.type = FWNODE_PDATA;
>  	set_secondary_fwnode(dev, &pset->fwnode);
>  }
>  EXPORT_SYMBOL_GPL(device_add_property_set);
> 

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2015-08-05 22:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-05 13:51 [PATCH 1/1] device property: fix potential NULL pointer dereference Andy Shevchenko
2015-08-05 23:20 ` Rafael J. Wysocki

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).