All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>, Jun Li <jun.li@nxp.com>
Cc: <linux-usb@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <support.opensource@diasemi.com>
Subject: [PATCH v8 3/6] power: supply: Add error checking of psy desc during registration
Date: Mon, 23 Apr 2018 15:10:58 +0100	[thread overview]
Message-ID: <627b8dcdee758c2598c6cf68b0ce536d3e557ca4.1524490253.git.Adam.Thomson.Opensource@diasemi.com> (raw)
In-Reply-To: <cover.1524490253.git.Adam.Thomson.Opensource@diasemi.com>

Currently there's no error checking of this parameter in the
registration function and it's blindly added to psy class and
subsequently used as is. For example if this is NULL the call
to psy_register_thermal() will try to dereference the pointer
thus causing a kernel dump.

This commit updates the registration code to add some basic
checks on the desc pointer validity, name, and presence of
properties.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
---
 drivers/power/supply/power_supply_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index feac7b0..a7984af 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -849,6 +849,9 @@ static void psy_unregister_cooler(struct power_supply *psy)
 		pr_warn("%s: Expected proper parent device for '%s'\n",
 			__func__, desc->name);
 
+	if (!desc || !desc->name || !desc->properties || !desc->num_properties)
+		return ERR_PTR(-EINVAL);
+
 	psy = kzalloc(sizeof(*psy), GFP_KERNEL);
 	if (!psy)
 		return ERR_PTR(-ENOMEM);
-- 
1.9.1


WARNING: multiple messages have this Message-ID (diff)
From: "Opensource \[Adam Thomson\]" <Adam.Thomson.Opensource@diasemi.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>, Jun Li <jun.li@nxp.com>
Cc: linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, support.opensource@diasemi.com
Subject: [v8,3/6] power: supply: Add error checking of psy desc during registration
Date: Mon, 23 Apr 2018 15:10:58 +0100	[thread overview]
Message-ID: <627b8dcdee758c2598c6cf68b0ce536d3e557ca4.1524490253.git.Adam.Thomson.Opensource@diasemi.com> (raw)

Currently there's no error checking of this parameter in the
registration function and it's blindly added to psy class and
subsequently used as is. For example if this is NULL the call
to psy_register_thermal() will try to dereference the pointer
thus causing a kernel dump.

This commit updates the registration code to add some basic
checks on the desc pointer validity, name, and presence of
properties.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 drivers/power/supply/power_supply_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index feac7b0..a7984af 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -849,6 +849,9 @@ static void psy_unregister_cooler(struct power_supply *psy)
 		pr_warn("%s: Expected proper parent device for '%s'\n",
 			__func__, desc->name);
 
+	if (!desc || !desc->name || !desc->properties || !desc->num_properties)
+		return ERR_PTR(-EINVAL);
+
 	psy = kzalloc(sizeof(*psy), GFP_KERNEL);
 	if (!psy)
 		return ERR_PTR(-ENOMEM);

WARNING: multiple messages have this Message-ID (diff)
From: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>, Jun Li <jun.li@nxp.com>
Cc: linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, support.opensource@diasemi.com
Subject: [PATCH v8 3/6] power: supply: Add error checking of psy desc during registration
Date: Mon, 23 Apr 2018 15:10:58 +0100	[thread overview]
Message-ID: <627b8dcdee758c2598c6cf68b0ce536d3e557ca4.1524490253.git.Adam.Thomson.Opensource@diasemi.com> (raw)
In-Reply-To: <cover.1524490253.git.Adam.Thomson.Opensource@diasemi.com>

Currently there's no error checking of this parameter in the
registration function and it's blindly added to psy class and
subsequently used as is. For example if this is NULL the call
to psy_register_thermal() will try to dereference the pointer
thus causing a kernel dump.

This commit updates the registration code to add some basic
checks on the desc pointer validity, name, and presence of
properties.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
---
 drivers/power/supply/power_supply_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index feac7b0..a7984af 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -849,6 +849,9 @@ static void psy_unregister_cooler(struct power_supply *psy)
 		pr_warn("%s: Expected proper parent device for '%s'\n",
 			__func__, desc->name);
 
+	if (!desc || !desc->name || !desc->properties || !desc->num_properties)
+		return ERR_PTR(-EINVAL);
+
 	psy = kzalloc(sizeof(*psy), GFP_KERNEL);
 	if (!psy)
 		return ERR_PTR(-ENOMEM);
-- 
1.9.1

  parent reply	other threads:[~2018-04-23 14:14 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 14:10 [PATCH v8 0/6] typec: tcpm: Add sink side support for PPS Adam Thomson
2018-04-23 14:10 ` Adam Thomson
2018-04-23 14:10 ` [PATCH v8 1/6] typec: tcpm: Add core support for sink side PPS Adam Thomson
2018-04-23 14:10   ` Adam Thomson
2018-04-23 14:10   ` [v8,1/6] " Opensource [Adam Thomson]
2018-04-23 14:10 ` [PATCH v8 2/6] Documentation: power: Initial effort to document power_supply ABI Adam Thomson
2018-04-23 14:10   ` Adam Thomson
2018-04-23 14:10   ` [v8,2/6] " Opensource [Adam Thomson]
2018-04-24 12:40   ` [PATCH v8 2/6] " Heikki Krogerus
2018-04-24 12:40     ` [v8,2/6] " Heikki Krogerus
2018-04-23 14:10 ` Adam Thomson [this message]
2018-04-23 14:10   ` [PATCH v8 3/6] power: supply: Add error checking of psy desc during registration Adam Thomson
2018-04-23 14:10   ` [v8,3/6] " Opensource [Adam Thomson]
2018-04-24 12:42   ` [PATCH v8 3/6] " Heikki Krogerus
2018-04-24 12:42     ` [v8,3/6] " Heikki Krogerus
2018-04-23 14:10 ` [PATCH v8 4/6] power: supply: Add 'usb_type' property and supporting code Adam Thomson
2018-04-23 14:10   ` Adam Thomson
2018-04-23 14:10   ` [v8,4/6] " Opensource [Adam Thomson]
2018-04-24 12:46   ` [PATCH v8 4/6] " Heikki Krogerus
2018-04-24 12:46     ` [v8,4/6] " Heikki Krogerus
2018-04-23 14:11 ` [PATCH v8 5/6] typec: tcpm: Represent source supply through power_supply Adam Thomson
2018-04-23 14:11   ` Adam Thomson
2018-04-23 14:11   ` [v8,5/6] " Opensource [Adam Thomson]
2018-04-24 12:47   ` [PATCH v8 5/6] " Heikki Krogerus
2018-04-24 12:47     ` [v8,5/6] " Heikki Krogerus
2018-04-23 14:11 ` [PATCH v8 6/6] typec: tcpm: Add support for sink PPS related messages Adam Thomson
2018-04-23 14:11   ` Adam Thomson
2018-04-23 14:11   ` [v8,6/6] " Opensource [Adam Thomson]
2018-04-24 13:57 ` [PATCH v8 0/6] typec: tcpm: Add sink side support for PPS Greg Kroah-Hartman
2018-04-24 23:26   ` Sebastian Reichel
2018-04-25 12:30     ` Greg Kroah-Hartman
2018-04-25 13:13       ` Adam Thomson
2018-04-26  7:33       ` Greg Kroah-Hartman
2018-04-26 10:54         ` Sebastian Reichel

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=627b8dcdee758c2598c6cf68b0ce536d3e557ca4.1524490253.git.Adam.Thomson.Opensource@diasemi.com \
    --to=adam.thomson.opensource@diasemi.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jun.li@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=sre@kernel.org \
    --cc=support.opensource@diasemi.com \
    /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.