Skip to content
/ linux Public

Commit f1ba620

Browse files
jhovoldSasha Levin
authored andcommitted
most: core: fix leak on early registration failure
[ Upstream commit 2c198c2 ] A recent commit fixed a resource leak on early registration failures but for some reason left out the first error path which still leaks the resources associated with the interface. Fix up also the first error path so that the interface is always released on errors. Fixes: 1f4c9d8 ("most: core: fix resource leak in most_register_interface error paths") Fixes: 723de0f ("staging: most: remove device from interface structure") Cc: Christian Gromm <christian.gromm@microchip.com> Cc: Navaneeth K <knavaneeth786@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260116162950.21578-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c954666 commit f1ba620

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/most/core.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,12 +1282,17 @@ int most_register_interface(struct most_interface *iface)
12821282
int id;
12831283
struct most_channel *c;
12841284

1285-
if (!iface || !iface->enqueue || !iface->configure ||
1286-
!iface->poison_channel || (iface->num_channels > MAX_CHANNELS))
1285+
if (!iface)
12871286
return -EINVAL;
12881287

12891288
device_initialize(iface->dev);
12901289

1290+
if (!iface->enqueue || !iface->configure || !iface->poison_channel ||
1291+
(iface->num_channels > MAX_CHANNELS)) {
1292+
put_device(iface->dev);
1293+
return -EINVAL;
1294+
}
1295+
12911296
id = ida_alloc(&mdev_id, GFP_KERNEL);
12921297
if (id < 0) {
12931298
dev_err(iface->dev, "Failed to allocate device ID\n");

0 commit comments

Comments
 (0)