]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mcb: fix error handling for different scenarios when parsing
authorSanjuán García, Jorge <Jorge.SanjuanGarcia@duagon.com>
Thu, 19 Oct 2023 14:15:34 +0000 (14:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:45:45 +0000 (16:45 +0000)
commit 63ba2d07b4be72b94216d20561f43e1150b25d98 upstream.

chameleon_parse_gdd() may fail for different reasons and end up
in the err tag. Make sure we at least 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()")
Cc: stable <stable@kernel.org>
Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
Link: https://lore.kernel.org/r/20231019141434.57971-2-jorge.sanjuangarcia@duagon.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mcb/mcb-core.c
drivers/mcb/mcb-parse.c

index 6e7e91387f3c468a60c7fb066ffcdabd8c2d7f2c..c8c6d217aaa94080e5495f08b0ca84bedb0fcc48 100644 (file)
@@ -251,6 +251,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
        return 0;
 
 out:
+       put_device(&dev->dev);
 
        return ret;
 }
index b7354232221e6871eddbd1dbba4cacb4877e1d53..6bb6be4bb40ab58f24030c0769b77dd5ff5c0792 100644 (file)
@@ -105,7 +105,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
        return 0;
 
 err:
-       put_device(&mdev->dev);
+       mcb_free_dev(mdev);
 
        return ret;
 }