linux/drivers/xen/xenbus
Qiu-ji Chen afc545da38 xen: Fix the issue of resource not being properly released in xenbus_dev_probe()
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: 4bac07c993 ("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>
Message-ID: <20241105130919.4621-1-chenqiuji666@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
2024-11-13 20:11:26 +01:00
..
Makefile xen/xenbus: Use *-y instead of *-objs in Makefile 2024-05-17 12:14:13 +02:00
xenbus_client.c xen/xenbus: document will_handle argument for xenbus_watch_path() 2024-02-12 18:03:14 +01:00
xenbus_comms.c xen: Fix event channel callback via INTX/GSI 2021-01-13 16:12:00 +01:00
xenbus_dev_backend.c
xenbus_dev_frontend.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
xenbus_probe_backend.c xenbus/backend: dynamically allocate the xen-backend shrinker 2023-10-04 10:32:23 -07:00
xenbus_probe_frontend.c xen: xenbus: Use helper function IS_ERR_OR_NULL() 2023-08-21 09:55:11 +02:00
xenbus_probe.c xen: Fix the issue of resource not being properly released in xenbus_dev_probe() 2024-11-13 20:11:26 +01:00
xenbus_xs.c xen/xenbus: Convert to use ERR_CAST() 2024-09-12 08:25:13 +02:00
xenbus.h driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00