* [PATCH] mcb: fix error handling for different scenarios when parsing
@ 2023-09-06 14:36 Sanjuán García, Jorge
2023-09-07 1:31 ` Yang Yingliang
0 siblings, 1 reply; 2+ messages in thread
From: Sanjuán García, Jorge @ 2023-09-06 14:36 UTC (permalink / raw)
To: jirislaby
Cc: morbidrsa, linux-kernel, jth, Rodríguez Barbarin,
José Javier, yangyingliang, Sanjuán García, Jorge
chameleon_parse_gdd() may fail for different reasons and end up
in the err tag. Make sure we at least make sure we always free
the mcb_device allocated with mcb_alloc_dev().
If mcb_device_register() fails, make sure to give up the reference
in the same place the device was added.
Fixes: 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")
Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
---
drivers/mcb/mcb-core.c | 1 +
drivers/mcb/mcb-parse.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 2f23b9c3b751..f797d078978f 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -247,6 +247,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
return 0;
out:
+ put_device(&dev->dev);
return ret;
}
diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 656b6b71c768..1ae37e693de0 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -106,7 +106,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
return 0;
err:
- put_device(&mdev->dev);
+ mcb_free_dev(mdev);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mcb: fix error handling for different scenarios when parsing
2023-09-06 14:36 [PATCH] mcb: fix error handling for different scenarios when parsing Sanjuán García, Jorge
@ 2023-09-07 1:31 ` Yang Yingliang
0 siblings, 0 replies; 2+ messages in thread
From: Yang Yingliang @ 2023-09-07 1:31 UTC (permalink / raw)
To: Sanjuán García, Jorge, jirislaby
Cc: morbidrsa, linux-kernel, jth, Rodríguez Barbarin, José Javier
On 2023/9/6 22:36, Sanjuán García, Jorge wrote:
> chameleon_parse_gdd() may fail for different reasons and end up
> in the err tag. Make sure we at least make sure we always free
> the mcb_device allocated with mcb_alloc_dev().
>
> If mcb_device_register() fails, make sure to give up the reference
> in the same place the device was added.
>
> Fixes: 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")
> Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
> Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-07 1:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06 14:36 [PATCH] mcb: fix error handling for different scenarios when parsing Sanjuán García, Jorge
2023-09-07 1:31 ` Yang Yingliang
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®