mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Qiu-ji Chen <chenqiuji666@gmail.com>,
	sstabellini@kernel.org, oleksandr_tyshchenko@epam.com,
	gregkh@linuxfoundation.org, sumit.garg@linaro.org,
	xin.wang2@amd.com
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
	baijiaju1990@gmail.com, stable@vger.kernel.org
Subject: Re: [PATCH] xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
Date: Tue, 5 Nov 2024 16:56:37 +0100	[thread overview]
Message-ID: <79984ce2-98a2-42f4-85f8-fd53d71f10c7@suse.com> (raw)
In-Reply-To: <20241105130919.4621-1-chenqiuji666@gmail.com>


[-- Attachment #1.1.1: Type: text/plain, Size: 1629 bytes --]

On 05.11.24 14:09, Qiu-ji Chen wrote:
> This patch fixes an issue in the function xenbus_dev_probe(). In the
> xenbus_dev_probe() function, within the if (err) branch at line 313, the
> program incorrectly returns err directly without releasing the resources
> allocated by err = drv->probe(dev, id). As the return value is non-zero,
> the upper layers assume the processing logic has failed. However, the probe
> operation was performed earlier without a corresponding remove operation.
> Since the probe actually allocates resources, failing to perform the remove
> operation could lead to problems.
> 
> To fix this issue, we followed the resource release logic of the
> xenbus_dev_remove() function by adding a new block fail_remove before the
> fail_put block. After entering the branch if (err) at line 313, the
> function will use a goto statement to jump to the fail_remove block,
> ensuring that the previously acquired resources are correctly released,
> thus preventing the reference count leak.
> 
> This bug was identified by an experimental static analysis tool developed
> by our team. The tool specializes in analyzing reference count operations
> and detecting potential issues where resources are not properly managed.
> In this case, the tool flagged the missing release operation as a
> potential problem, which led to the development of this patch.
> 
> Fixes: 4bac07c993d0 ("xen: add the Xenbus sysfs and virtual device hotplug driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

      reply	other threads:[~2024-11-05 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-05 13:09 Qiu-ji Chen
2024-11-05 15:56 ` Jürgen Groß [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=79984ce2-98a2-42f4-85f8-fd53d71f10c7@suse.com \
    --to=jgross@suse.com \
    --cc=baijiaju1990@gmail.com \
    --cc=chenqiuji666@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sumit.garg@linaro.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xin.wang2@amd.com \
    /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

all inboxes | Powered by JetHome®