linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: atmel-sdramc: fix a possible NULL dereference
@ 2016-08-16 13:53 LABBE Corentin
  2016-08-31 17:20 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: LABBE Corentin @ 2016-08-16 13:53 UTC (permalink / raw)
  To: alexandre.belloni, paul.gortmaker, nicolas.ferre
  Cc: linux-kernel, LABBE Corentin

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

For fixing this problem, we use of_device_get_match_data(), this will
simplify the code a little by using a standard function for
getting the match data.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/memory/atmel-sdramc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c
index 53a341f..12080b0 100644
--- a/drivers/memory/atmel-sdramc.c
+++ b/drivers/memory/atmel-sdramc.c
@@ -53,12 +53,10 @@ static const struct of_device_id atmel_ramc_of_match[] = {
 
 static int atmel_ramc_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	const struct at91_ramc_caps *caps;
 	struct clk *clk;
 
-	match = of_match_device(atmel_ramc_of_match, &pdev->dev);
-	caps = match->data;
+	caps = of_device_get_match_data(&pdev->dev);
 
 	if (caps->has_ddrck) {
 		clk = devm_clk_get(&pdev->dev, "ddrck");
-- 
2.7.3

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

* Re: [PATCH] memory: atmel-sdramc: fix a possible NULL dereference
  2016-08-16 13:53 [PATCH] memory: atmel-sdramc: fix a possible NULL dereference LABBE Corentin
@ 2016-08-31 17:20 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2016-08-31 17:20 UTC (permalink / raw)
  To: LABBE Corentin; +Cc: paul.gortmaker, nicolas.ferre, linux-kernel

On 16/08/2016 at 15:53:18 +0200, LABBE Corentin wrote :
> of_match_device could return NULL, and so cause a NULL pointer
> dereference later.
> 
> For fixing this problem, we use of_device_get_match_data(), this will
> simplify the code a little by using a standard function for
> getting the match data.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/memory/atmel-sdramc.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
Applied, thanks.

-- 
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:[~2016-08-31 17:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 13:53 [PATCH] memory: atmel-sdramc: fix a possible NULL dereference LABBE Corentin
2016-08-31 17:20 ` Alexandre Belloni

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).