Skip to content

Commit

Permalink
mcb: fix error handling for different scenarios when parsing
Browse files Browse the repository at this point in the history
commit 63ba2d0 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: 728ac33 ("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>
  • Loading branch information
mad-jsanjuan authored and gregkh committed Nov 28, 2023
1 parent b2f0034 commit 5f74466
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/mcb/mcb-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
return 0;

out:
put_device(&dev->dev);

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/mcb/mcb-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5f74466

Please sign in to comment.