linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: wu000273@umn.edu
Cc: kjlu@umn.edu,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Enrico Weigelt <info@metux.net>,
	Allison Randal <allison@lohutok.net>,
	Alexios Zavras <alexios.zavras@intel.com>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Rob Clark <robdclark@gmail.com>, Dave Airlie <airlied@gmail.com>,
	linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] omapfb: Fix reference count leak in display_init_sysfs.
Date: Fri, 29 May 2020 10:22:31 +0200	[thread overview]
Message-ID: <20200529082231.GA847132@kroah.com> (raw)
In-Reply-To: <20200528194424.11596-1-wu000273@umn.edu>

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

      reply	other threads:[~2020-05-29  8:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 19:44 [PATCH] omapfb: Fix reference count leak in display_init_sysfs wu000273
2020-05-29  8:22 ` Greg Kroah-Hartman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200529082231.GA847132@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=airlied@gmail.com \
    --cc=alexios.zavras@intel.com \
    --cc=allison@lohutok.net \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=info@metux.net \
    --cc=kjlu@umn.edu \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tomi.valkeinen@ti.com \
    --cc=wu000273@umn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).