public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Bart Van Assche <bvanassche@acm.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs: sysfs: Fix reference leak in sysfs_break_active_protection()
Date: Wed, 13 Mar 2024 11:44:32 -1000	[thread overview]
Message-ID: <ZfIeQKluEeh7TulW@slm.duckdns.org> (raw)
In-Reply-To: <8a4d3f0f-c5e3-4b70-a188-0ca433f9e6f9@rowland.harvard.edu>

On Wed, Mar 13, 2024 at 05:43:41PM -0400, Alan Stern wrote:
> The sysfs_break_active_protection() routine has an obvious reference
> leak in its error path.  If the call to kernfs_find_and_get() fails then
> kn will be NULL, so the companion sysfs_unbreak_active_protection()
> routine won't get called (and would only cause an access violation by
> trying to dereference kn->parent if it was called).  As a result, the
> reference to kobj acquired at the start of the function will never be
> released.
> 
> Fix the leak by adding an explicit kobject_put() call when kn is NULL.
> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> Fixes: 2afc9166f79b ("scsi: sysfs: Introduce sysfs_{un,}break_active_protection()")
> Cc: Bart Van Assche <bvanassche@acm.org>
> Cc: <stable@vger.kernel.org>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

  reply	other threads:[~2024-03-13 21:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 12:10 [Bug] INFO: task hung in hub_activate Sam Sun
2024-03-04 13:37 ` Hillf Danton
2024-03-04 14:59 ` Alan Stern
2024-03-04 16:15 ` Alan Stern
2024-03-04 16:36   ` Greg KH
2024-03-04 18:30     ` Alan Stern
2024-03-04 19:17       ` Bug in sysfs_break_active_protection() Alan Stern
2024-03-13 20:21         ` Tejun Heo
2024-03-13 21:43           ` [PATCH] fs: sysfs: Fix reference leak " Alan Stern
2024-03-13 21:44             ` Tejun Heo [this message]
2024-03-13 22:10             ` Bart Van Assche
2024-03-05 12:03       ` [Bug] INFO: task hung in hub_activate Greg KH
2024-03-07 20:35 ` Alan Stern
2024-03-08  2:48   ` Sam Sun

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=ZfIeQKluEeh7TulW@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.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