public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe()
@ 2011-11-27 12:07 Axel Lin
  2011-11-27 19:46 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-11-27 12:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rajendra Nayak, Liam Girdwood, Mark Brown

of_get_fixed_voltage_config() may return NULL, return -ENOMEM in this case
so we don't dereference NULL pointer.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/fixed.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 6828dce..72abbf5 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -163,12 +163,17 @@ static struct regulator_ops fixed_voltage_ops = {
 
 static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 {
-	struct fixed_voltage_config *config = pdev->dev.platform_data;
+	struct fixed_voltage_config *config;
 	struct fixed_voltage_data *drvdata;
 	int ret;
 
 	if (pdev->dev.of_node)
 		config = of_get_fixed_voltage_config(&pdev->dev);
+	else
+		config = pdev->dev.platform_data;
+
+	if (!config)
+		return -ENOMEM;
 
 	drvdata = kzalloc(sizeof(struct fixed_voltage_data), GFP_KERNEL);
 	if (drvdata == NULL) {
-- 
1.7.5.4




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

* Re: [PATCH v2] regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe()
  2011-11-27 12:07 [PATCH v2] regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe() Axel Lin
@ 2011-11-27 19:46 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2011-11-27 19:46 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Rajendra Nayak, Liam Girdwood

On Sun, Nov 27, 2011 at 08:07:57PM +0800, Axel Lin wrote:
> of_get_fixed_voltage_config() may return NULL, return -ENOMEM in this case
> so we don't dereference NULL pointer.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>

Applied, thanks.

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

end of thread, other threads:[~2011-11-27 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-27 12:07 [PATCH v2] regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe() Axel Lin
2011-11-27 19:46 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox