linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shailendra Verma <shailendra.v@samsung.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org, p.shailesh@samsung.com,
	ashish.kalra@samsung.com,
	Shailendra Verma <shailendra.v@samsung.com>,
	Shailendra Verma <shailendra.capricorn@gmail.com>
Subject: [PATCH] Regulator - Fix possible NULL derefrence.
Date: Mon, 30 Jan 2017 10:23:07 +0530	[thread overview]
Message-ID: <1485751987-29397-1-git-send-email-shailendra.v@samsung.com> (raw)
In-Reply-To: CGME20170130045313epcas4p3c12d9c557946f31fa6a410dfee62424e@epcas4p3.samsung.com

of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/regulator/qcom_rpm-regulator.c |    4 ++++
 drivers/regulator/qcom_smd-regulator.c |    4 ++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 1b2acc4..8a03db8 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -959,6 +959,10 @@ static int rpm_reg_probe(struct platform_device *pdev)
 	}
 
 	match = of_match_device(rpm_of_match, &pdev->dev);
+	if (!match) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
 	for (reg = match->data; reg->name; reg++) {
 		vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
 		if (!vreg)
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 8ed46a9..967f2b6 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -468,6 +468,10 @@ static int rpm_reg_probe(struct platform_device *pdev)
 	}
 
 	match = of_match_device(rpm_of_match, &pdev->dev);
+	if (!match) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
 	for (reg = match->data; reg->name; reg++) {
 		vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
 		if (!vreg)
-- 
1.7.9.5

           reply	other threads:[~2017-01-30  4:53 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <CGME20170130045313epcas4p3c12d9c557946f31fa6a410dfee62424e@epcas4p3.samsung.com>]

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=1485751987-29397-1-git-send-email-shailendra.v@samsung.com \
    --to=shailendra.v@samsung.com \
    --cc=ashish.kalra@samsung.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.shailesh@samsung.com \
    --cc=shailendra.capricorn@gmail.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 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).