* [PATCH] drivers/video/fbdev : dereference without an error test
@ 2014-06-21 15:58 ` Himangi Saraogi
0 siblings, 0 replies; 4+ messages in thread
From: Himangi Saraogi @ 2014-06-21 15:57 UTC (permalink / raw)
To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev,
linux-kernel
Cc: julia.lawall
After a variable is assigned the result of backlight_device_register, an
error test should be performed before a dereference.
A simplified version of the semantic match that finds this problem is
as follows:
// <smpl>
@def0@
expression x;
position p0;
@@
x@p0 = backlight_device_register(...)
@protected@
expression def0.x,E;
position def0.p0;
position p;
statement S;
@@
x@p0
... when != x = E
if (!IS_ERR(x) && ...) {<... x@p ...>} else S
@unprotected@
expression def0.x,E;
identifier fld;
position def0.p0;
position p != protected.p;
@@
x@p0
... when != x = E
* x@p->fld
// </smpl>
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
index c7ba4d8..acd9ff1 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
@@ -817,6 +817,10 @@ static int acx565akm_probe(struct spi_device *spi)
bldev = backlight_device_register("acx565akm", &ddata->spi->dev,
ddata, &acx565akm_bl_ops, &props);
+ if (IS_ERR(bldev)) {
+ r = PTR_ERR(bldev);
+ goto err_reg;
+ }
ddata->bl_dev = bldev;
if (ddata->has_cabc) {
r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
@@ -862,6 +866,7 @@ err_reg:
sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group);
err_sysfs:
backlight_device_unregister(bldev);
+err_reg:
err_detect:
err_gpio:
omap_dss_put_device(ddata->in);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] drivers/video/fbdev : dereference without an error test
@ 2014-06-21 15:58 ` Himangi Saraogi
0 siblings, 0 replies; 4+ messages in thread
From: Himangi Saraogi @ 2014-06-21 15:58 UTC (permalink / raw)
To: Jean-Christophe Plagniol-Villard, Tomi Valkeinen, linux-fbdev,
linux-kernel
Cc: julia.lawall
After a variable is assigned the result of backlight_device_register, an
error test should be performed before a dereference.
A simplified version of the semantic match that finds this problem is
as follows:
// <smpl>
@def0@
expression x;
position p0;
@@
x@p0 = backlight_device_register(...)
@protected@
expression def0.x,E;
position def0.p0;
position p;
statement S;
@@
x@p0
... when != x = E
if (!IS_ERR(x) && ...) {<... x@p ...>} else S
@unprotected@
expression def0.x,E;
identifier fld;
position def0.p0;
position p != protected.p;
@@
x@p0
... when != x = E
* x@p->fld
// </smpl>
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
index c7ba4d8..acd9ff1 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
@@ -817,6 +817,10 @@ static int acx565akm_probe(struct spi_device *spi)
bldev = backlight_device_register("acx565akm", &ddata->spi->dev,
ddata, &acx565akm_bl_ops, &props);
+ if (IS_ERR(bldev)) {
+ r = PTR_ERR(bldev);
+ goto err_reg;
+ }
ddata->bl_dev = bldev;
if (ddata->has_cabc) {
r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
@@ -862,6 +866,7 @@ err_reg:
sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group);
err_sysfs:
backlight_device_unregister(bldev);
+err_reg:
err_detect:
err_gpio:
omap_dss_put_device(ddata->in);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers/video/fbdev : dereference without an error test
2014-06-21 15:58 ` Himangi Saraogi
@ 2014-06-26 10:48 ` Tomi Valkeinen
-1 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2014-06-26 10:48 UTC (permalink / raw)
To: Himangi Saraogi, Jean-Christophe Plagniol-Villard, linux-fbdev,
linux-kernel
Cc: julia.lawall
[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]
On 21/06/14 18:57, Himangi Saraogi wrote:
> After a variable is assigned the result of backlight_device_register, an
> error test should be performed before a dereference.
>
> A simplified version of the semantic match that finds this problem is
> as follows:
>
> // <smpl>
> @def0@
> expression x;
> position p0;
> @@
>
> x@p0 = backlight_device_register(...)
>
> @protected@
> expression def0.x,E;
> position def0.p0;
> position p;
> statement S;
> @@
> x@p0
> ... when != x = E
> if (!IS_ERR(x) && ...) {<... x@p ...>} else S
>
> @unprotected@
> expression def0.x,E;
> identifier fld;
> position def0.p0;
> position p != protected.p;
> @@
> x@p0
> ... when != x = E
> * x@p->fld
> // </smpl>
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> index c7ba4d8..acd9ff1 100644
> --- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> +++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> @@ -817,6 +817,10 @@ static int acx565akm_probe(struct spi_device *spi)
>
> bldev = backlight_device_register("acx565akm", &ddata->spi->dev,
> ddata, &acx565akm_bl_ops, &props);
> + if (IS_ERR(bldev)) {
> + r = PTR_ERR(bldev);
> + goto err_reg;
> + }
> ddata->bl_dev = bldev;
> if (ddata->has_cabc) {
> r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
> @@ -862,6 +866,7 @@ err_reg:
> sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group);
> err_sysfs:
> backlight_device_unregister(bldev);
> +err_reg:
> err_detect:
> err_gpio:
> omap_dss_put_device(ddata->in);
Thanks. This didn't compile, as there already was a "err_reg" label
defined. I fixed the issue, and queued for 3.17.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drivers/video/fbdev : dereference without an error test
@ 2014-06-26 10:48 ` Tomi Valkeinen
0 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2014-06-26 10:48 UTC (permalink / raw)
To: Himangi Saraogi, Jean-Christophe Plagniol-Villard, linux-fbdev,
linux-kernel
Cc: julia.lawall
[-- Attachment #1: Type: text/plain, Size: 2043 bytes --]
On 21/06/14 18:57, Himangi Saraogi wrote:
> After a variable is assigned the result of backlight_device_register, an
> error test should be performed before a dereference.
>
> A simplified version of the semantic match that finds this problem is
> as follows:
>
> // <smpl>
> @def0@
> expression x;
> position p0;
> @@
>
> x@p0 = backlight_device_register(...)
>
> @protected@
> expression def0.x,E;
> position def0.p0;
> position p;
> statement S;
> @@
> x@p0
> ... when != x = E
> if (!IS_ERR(x) && ...) {<... x@p ...>} else S
>
> @unprotected@
> expression def0.x,E;
> identifier fld;
> position def0.p0;
> position p != protected.p;
> @@
> x@p0
> ... when != x = E
> * x@p->fld
> // </smpl>
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> index c7ba4d8..acd9ff1 100644
> --- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> +++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
> @@ -817,6 +817,10 @@ static int acx565akm_probe(struct spi_device *spi)
>
> bldev = backlight_device_register("acx565akm", &ddata->spi->dev,
> ddata, &acx565akm_bl_ops, &props);
> + if (IS_ERR(bldev)) {
> + r = PTR_ERR(bldev);
> + goto err_reg;
> + }
> ddata->bl_dev = bldev;
> if (ddata->has_cabc) {
> r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
> @@ -862,6 +866,7 @@ err_reg:
> sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group);
> err_sysfs:
> backlight_device_unregister(bldev);
> +err_reg:
> err_detect:
> err_gpio:
> omap_dss_put_device(ddata->in);
Thanks. This didn't compile, as there already was a "err_reg" label
defined. I fixed the issue, and queued for 3.17.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-26 10:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-21 15:57 [PATCH] drivers/video/fbdev : dereference without an error test Himangi Saraogi
2014-06-21 15:58 ` Himangi Saraogi
2014-06-26 10:48 ` Tomi Valkeinen
2014-06-26 10:48 ` Tomi Valkeinen
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.