2022-12-02 10:03:23

by Johannes Thumshirn

[permalink] [raw]
Subject: [PATCH 0/2] drivers: mcb: collected patches for 6.2

From: Johannes Thumshirn <[email protected]>

Hi Greg,

Here are the patches I've collected for drivers mcb for v6.2.
Both fix problems in the error paths.

I'm sorry I know I'm ultra late with this.

Thanks,
Johannes

Yang Yingliang (1):
mcb: mcb-parse: fix error handing in chameleon_parse_gdd()

Zhengchao Shao (1):
drivers: mcb: fix resource leak in mcb_probe()

drivers/mcb/mcb-core.c | 4 +++-
drivers/mcb/mcb-parse.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)

--
2.37.3


2022-12-02 10:11:29

by Johannes Thumshirn

[permalink] [raw]
Subject: [PATCH 1/2] drivers: mcb: fix resource leak in mcb_probe()

From: Zhengchao Shao <[email protected]>

When probe hook function failed in mcb_probe(), it doesn't put the device.
Compiled test only.

Fixes: 7bc364097a89 ("mcb: Acquire reference to device in probe")
Signed-off-by: Zhengchao Shao <[email protected]>
Signed-off-by: Johannes Thumshirn <[email protected]>
---
drivers/mcb/mcb-core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 338fc889b357..b8ad4f16b4ac 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -71,8 +71,10 @@ static int mcb_probe(struct device *dev)

get_device(dev);
ret = mdrv->probe(mdev, found_id);
- if (ret)
+ if (ret) {
module_put(carrier_mod);
+ put_device(dev);
+ }

return ret;
}
--
2.37.3

2022-12-02 10:28:33

by Johannes Thumshirn

[permalink] [raw]
Subject: [PATCH 2/2] mcb: mcb-parse: fix error handing in chameleon_parse_gdd()

From: Yang Yingliang <[email protected]>

If mcb_device_register() returns error in chameleon_parse_gdd(), the refcount
of bus and device name are leaked. Fix this by calling put_device() to give up
the reference, so they can be released in mcb_release_dev() and kobject_cleanup().

Fixes: 3764e82e5150 ("drivers: Introduce MEN Chameleon Bus")
Signed-off-by: Yang Yingliang <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Johannes Thumshirn <[email protected]>
---
drivers/mcb/mcb-parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 0266bfddfbe2..aa6938da0db8 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -108,7 +108,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
return 0;

err:
- mcb_free_dev(mdev);
+ put_device(&mdev->dev);

return ret;
}
--
2.37.3