Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1569397 > unrolled thread

[PATCH] Memory - Fix possible NULL derefrence.

Started byShailendra Verma <shailendra.v@samsung.com>
First post2017-01-30 06:20 +0100
Last post2017-01-30 09:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] Memory - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-30 06:20 +0100
    Re: [PATCH] Memory - Fix possible NULL derefrence. Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-01-30 09:00 +0100

#1569397 — [PATCH] Memory - Fix possible NULL derefrence.

FromShailendra Verma <shailendra.v@samsung.com>
Date2017-01-30 06:20 +0100
Subject[PATCH] Memory - Fix possible NULL derefrence.
Message-ID<t5cxI-8lg-1@gated-at.bofh.it>
of_device_get_match_data could return NULL, and so can cause
a NULL pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/memory/atmel-sdramc.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
index 12080b0..cb63fbe 100644
--- a/drivers/memory/atmel-sdramc.c
+++ b/drivers/memory/atmel-sdramc.c
@@ -57,6 +57,10 @@ static int atmel_ramc_probe(struct platform_device *pdev)
 	struct clk *clk;
 
 	caps = of_device_get_match_data(&pdev->dev);
+	if (!caps) {
+		dev_err(&pdev->dev, "no device match found\n");
+		return -ENODEV;
+	}
 
 	if (caps->has_ddrck) {
 		clk = devm_clk_get(&pdev->dev, "ddrck");
-- 
1.7.9.5

[toc] | [next] | [standalone]


#1569446

FromAlexandre Belloni <alexandre.belloni@free-electrons.com>
Date2017-01-30 09:00 +0100
Message-ID<t5f2x-1hX-1@gated-at.bofh.it>
In reply to#1569397
On 30/01/2017 at 10:30:05 +0530, Shailendra Verma wrote:
> of_device_get_match_data could return NULL, and so can cause
> a NULL pointer dereference later.
> 

No, it will never return NULL because it will always match.

At some point, I would really like people to stop blindly sending
patches generated by coccinelle.


-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web