Skip to contentSkip to conversation

drm/rockchip: fix NULL check on devm_kzalloc() return value

PATCH In review Gustavo A. R. Silva 3 participants 4 messages Jul 6, 2017 – Jul 11, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/rockchip: fix NULL check on devm_kzalloc() return value

The right variable to check here is port, not dp.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression x;
identifier fld;
@@

* x = devm_kzalloc(...);
... when != x == NULL
x->fld

---
 drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
index 14fa1f8..9b0b058 100644
@@ -1195,7 +1195,7 @@ static int cdn_dp_probe(struct platform_device *pdev)
 			continue;
 
 		port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
-		if (!dp)
+		if (!port)
 			return -ENOMEM;
 
 		port->extcon = extcon;
Signature · 1 line
2.5.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Gustavo A. R. Silva

The right variable to check here is port, not dp.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression x;
identifier fld;
@@

Quoted 5 lines
* x = devm_kzalloc(...);
   ... when != x == NULL
   x->fld

Thanks for the fix,

Quoted 17 lines
---
  drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
index 14fa1f8..9b0b058 100644
@@ -1195,7 +1195,7 @@ static int cdn_dp_probe(struct platform_device *pdev)
  			continue;
 
  		port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
-		if (!dp)
+		if (!port)
  			return -ENOMEM;
 
  		port->extcon = extcon;
Signature · 1 line
?ark Yao
#2 lore raw
Quoted 14 lines · Mark yao
Quoted 13 lines · Gustavo A. R. Silva

The right variable to check here is port, not dp.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression x;
identifier fld;
@@

* x = devm_kzalloc(...);
   ... when != x == NULL
   x->fld
Quoted 5 lines
Quoted 1 line

Thanks for the fix,

Hi Mark,
I've applied this patch, but in the future, please apply changes directly instead of just acking.

If you're unable to apply it for some reason (vacation, etc), please reach out to one of the -misc maintainers via email or irc so we don't inadvertently lose track of it on the list.

Sean

Quoted 26 lines
Quoted 16 lines
---
  drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
index 14fa1f8..9b0b058 100644
@@ -1195,7 +1195,7 @@ static int cdn_dp_probe(struct platform_device *pdev)
  			continue;
  		port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
-		if (!dp)
+		if (!port)
  			return -ENOMEM;
  		port->extcon = extcon;
Signature · 7 lines
?ark Yao


_______________________________________________
dri-devel mailing list
dri-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Sean Paul, Software Engineer, Google / Chromium OS
#3 lore raw
Quoted 23 lines · Sean Paul
Quoted 10 lines · Mark yao
Quoted 9 lines · Gustavo A. R. Silva

The right variable to check here is port, not dp.

This issue was detected using Coccinelle and the following semantic patch:

@@
expression x;
identifier fld;
@@

Quoted 8 lines
Quoted 5 lines
* x = devm_kzalloc(...);
    ... when != x == NULL
    x->fld

Thanks for the fix,

Hi Mark,
I've applied this patch, but in the future, please apply changes directly instead of just acking.

Quoted 5 lines

If you're unable to apply it for some reason (vacation, etc), please reach out to one of the -misc maintainers via email or irc so we don't inadvertently lose track of it on the list.

Sean

Hi Sean

Got it, I will do it right next time.
Thanks to inform me this,

Quoted 25 lines
Quoted 25 lines
Quoted 16 lines
---
   drivers/gpu/drm/rockchip/cdn-dp-core.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/rockchip/cdn-dp-core.c +1 -1
index 14fa1f8..9b0b058 100644
@@ -1195,7 +1195,7 @@ static int cdn_dp_probe(struct platform_device *pdev)
   			continue;
   		port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL);
-		if (!dp)
+		if (!port)
   			return -ENOMEM;
   		port->extcon = extcon;
Signature · 7 lines
?ark Yao


_______________________________________________
dri-devel mailing list
dri-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
?ark Yao