All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
@ 2020-05-28 19:44 ` wu000273
  0 siblings, 0 replies; 6+ messages in thread
From: wu000273 @ 2020-05-28 19:44 UTC (permalink / raw)
  To: kjlu
  Cc: wu000273, Bartlomiej Zolnierkiewicz, Thomas Gleixner,
	Greg Kroah-Hartman, Enrico Weigelt, Allison Randal,
	Alexios Zavras, Tomi Valkeinen, Rob Clark, Dave Airlie,
	linux-omap, linux-fbdev, dri-devel, linux-kernel

From: Qiushi Wu <wu000273@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.
Because function omap_dss_put_device() doesn't handle dssdev->kobj,
thus we need insert kobject_put() to clean up the kobject,
when kobject_init_and_add() fails.

Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
index 6dbe265b312d..51322ac7df07 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
@@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
 			&pdev->dev.kobj, "%s", dssdev->alias);
 		if (r) {
 			DSSERR("failed to create sysfs files\n");
+			kobject_put(&dssdev->kobj);
 			omap_dss_put_device(dssdev);
 			goto err;
 		}
-- 
2.17.1


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

* [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
@ 2020-05-28 19:44 ` wu000273
  0 siblings, 0 replies; 6+ messages in thread
From: wu000273 @ 2020-05-28 19:44 UTC (permalink / raw)
  To: kjlu
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, Greg Kroah-Hartman,
	linux-kernel, dri-devel, Alexios Zavras, Tomi Valkeinen,
	wu000273, Thomas Gleixner, linux-omap, Enrico Weigelt,
	Allison Randal

From: Qiushi Wu <wu000273@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.
Because function omap_dss_put_device() doesn't handle dssdev->kobj,
thus we need insert kobject_put() to clean up the kobject,
when kobject_init_and_add() fails.

Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
index 6dbe265b312d..51322ac7df07 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
@@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
 			&pdev->dev.kobj, "%s", dssdev->alias);
 		if (r) {
 			DSSERR("failed to create sysfs files\n");
+			kobject_put(&dssdev->kobj);
 			omap_dss_put_device(dssdev);
 			goto err;
 		}
-- 
2.17.1

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

* [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
@ 2020-05-28 19:44 ` wu000273
  0 siblings, 0 replies; 6+ messages in thread
From: wu000273 @ 2020-05-28 19:44 UTC (permalink / raw)
  To: kjlu
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, Greg Kroah-Hartman,
	linux-kernel, dri-devel, Alexios Zavras, Tomi Valkeinen,
	wu000273, Thomas Gleixner, linux-omap, Enrico Weigelt,
	Allison Randal

From: Qiushi Wu <wu000273@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.
Because function omap_dss_put_device() doesn't handle dssdev->kobj,
thus we need insert kobject_put() to clean up the kobject,
when kobject_init_and_add() fails.

Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
index 6dbe265b312d..51322ac7df07 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
@@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
 			&pdev->dev.kobj, "%s", dssdev->alias);
 		if (r) {
 			DSSERR("failed to create sysfs files\n");
+			kobject_put(&dssdev->kobj);
 			omap_dss_put_device(dssdev);
 			goto err;
 		}
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
  2020-05-28 19:44 ` wu000273
  (?)
@ 2020-05-29  8:22   ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-29  8:22 UTC (permalink / raw)
  To: wu000273
  Cc: kjlu, Bartlomiej Zolnierkiewicz, Thomas Gleixner, Enrico Weigelt,
	Allison Randal, Alexios Zavras, Tomi Valkeinen, Rob Clark,
	Dave Airlie, linux-omap, linux-fbdev, dri-devel, linux-kernel

On Thu, May 28, 2020 at 02:44:23PM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object.
> Because function omap_dss_put_device() doesn't handle dssdev->kobj,
> thus we need insert kobject_put() to clean up the kobject,
> when kobject_init_and_add() fails.
> 
> Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> index 6dbe265b312d..51322ac7df07 100644
> --- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> +++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> @@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
>  			&pdev->dev.kobj, "%s", dssdev->alias);
>  		if (r) {
>  			DSSERR("failed to create sysfs files\n");
> +			kobject_put(&dssdev->kobj);
>  			omap_dss_put_device(dssdev);
>  			goto err;
>  		}

Why is a driver creating "raw" kobjects and the like at all?

/me goes off to look...


Ick, no, that's not ok, this just needs to be an attribute group
attached to the device, no need for a kobject at all.  Having a kobject
means that the files will be ignored totally by userspace tools that
monitor sysfs changes.  So these files are probably not even being
used...

Please fix this up properly.

thanks,

greg k-h

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

* Re: [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
@ 2020-05-29  8:22   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-29  8:22 UTC (permalink / raw)
  To: wu000273
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kjlu, linux-kernel,
	dri-devel, Alexios Zavras, Tomi Valkeinen, Thomas Gleixner,
	linux-omap, Enrico Weigelt, Allison Randal

On Thu, May 28, 2020 at 02:44:23PM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object.
> Because function omap_dss_put_device() doesn't handle dssdev->kobj,
> thus we need insert kobject_put() to clean up the kobject,
> when kobject_init_and_add() fails.
> 
> Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> index 6dbe265b312d..51322ac7df07 100644
> --- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> +++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> @@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
>  			&pdev->dev.kobj, "%s", dssdev->alias);
>  		if (r) {
>  			DSSERR("failed to create sysfs files\n");
> +			kobject_put(&dssdev->kobj);
>  			omap_dss_put_device(dssdev);
>  			goto err;
>  		}

Why is a driver creating "raw" kobjects and the like at all?

/me goes off to look...


Ick, no, that's not ok, this just needs to be an attribute group
attached to the device, no need for a kobject at all.  Having a kobject
means that the files will be ignored totally by userspace tools that
monitor sysfs changes.  So these files are probably not even being
used...

Please fix this up properly.

thanks,

greg k-h

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

* Re: [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
@ 2020-05-29  8:22   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-29  8:22 UTC (permalink / raw)
  To: wu000273
  Cc: linux-fbdev, Bartlomiej Zolnierkiewicz, kjlu, linux-kernel,
	dri-devel, Alexios Zavras, Tomi Valkeinen, Thomas Gleixner,
	linux-omap, Enrico Weigelt, Allison Randal

On Thu, May 28, 2020 at 02:44:23PM -0500, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object.
> Because function omap_dss_put_device() doesn't handle dssdev->kobj,
> thus we need insert kobject_put() to clean up the kobject,
> when kobject_init_and_add() fails.
> 
> Fixes: f76ee892a99e ("omapfb: copy omapdss & displays for omapfb")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> index 6dbe265b312d..51322ac7df07 100644
> --- a/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> +++ b/drivers/video/fbdev/omap2/omapfb/dss/display-sysfs.c
> @@ -316,6 +316,7 @@ int display_init_sysfs(struct platform_device *pdev)
>  			&pdev->dev.kobj, "%s", dssdev->alias);
>  		if (r) {
>  			DSSERR("failed to create sysfs files\n");
> +			kobject_put(&dssdev->kobj);
>  			omap_dss_put_device(dssdev);
>  			goto err;
>  		}

Why is a driver creating "raw" kobjects and the like at all?

/me goes off to look...


Ick, no, that's not ok, this just needs to be an attribute group
attached to the device, no need for a kobject at all.  Having a kobject
means that the files will be ignored totally by userspace tools that
monitor sysfs changes.  So these files are probably not even being
used...

Please fix this up properly.

thanks,

greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2020-05-29  8:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 19:44 [PATCH] omapfb: Fix reference count leak in display_init_sysfs wu000273
2020-05-28 19:44 ` wu000273
2020-05-28 19:44 ` wu000273
2020-05-29  8:22 ` Greg Kroah-Hartman
2020-05-29  8:22   ` Greg Kroah-Hartman
2020-05-29  8:22   ` Greg Kroah-Hartman

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.