All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Memory - Fix possible NULL derefrence.
       [not found] <CGME20170130050046epcas2p381ef5bb7c8a1df4b8c7e37a93e168630@epcas2p3.samsung.com>
@ 2017-01-30  5:00 ` Shailendra Verma
  2017-01-30  7:59   ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Shailendra Verma @ 2017-01-30  5:00 UTC (permalink / raw)
  To: Alexandre Belloni, Paul Gortmaker, Nicolas Ferre, LABBE Corentin,
	linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma,
	Shailendra Verma

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

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

* Re: [PATCH] Memory - Fix possible NULL derefrence.
  2017-01-30  5:00 ` [PATCH] Memory - Fix possible NULL derefrence Shailendra Verma
@ 2017-01-30  7:59   ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-01-30  7:59 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Paul Gortmaker, Nicolas Ferre, LABBE Corentin, linux-kernel,
	p.shailesh, ashish.kalra, Shailendra Verma

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

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

end of thread, other threads:[~2017-01-30  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170130050046epcas2p381ef5bb7c8a1df4b8c7e37a93e168630@epcas2p3.samsung.com>
2017-01-30  5:00 ` [PATCH] Memory - Fix possible NULL derefrence Shailendra Verma
2017-01-30  7:59   ` Alexandre Belloni

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.