public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] regulator: Avoid potential NULL dereference in reg_fixed_voltage_probe()
@ 2011-11-27  2:13 Axel Lin
  2011-11-27 11:35 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2011-11-27  2:13 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 |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 639e19d..2f917a1 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -166,8 +166,11 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
 	struct fixed_voltage_data *drvdata;
 	int ret;
 
-	if (pdev->dev.of_node)
+	if (pdev->dev.of_node) {
 		config = of_get_fixed_voltage_config(&pdev->dev);
+		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] 4+ messages in thread

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

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

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