Re: [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()'

From: Saravana Kannan
Date: Sun Jan 24 2021 - 03:58:17 EST


On Sat, Jan 23, 2021 at 10:32 PM Christophe JAILLET
<christophe.jaillet@xxxxxxxxxx> wrote:
>
> In 'fw_devlink_create_devlink()', all exit paths, successful or not,
> release the reference taken on 'sup_dev'.
> All but this one.
>
> Use the existing error handling case to call the missing 'put_device()'.
>
> Fixes: f9aa460672c9c ("driver core: Refactor fw_devlink feature")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> ---
> Speculative and compile tested only
> ---
> drivers/base/core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index e08d376631cc..8775717a6bf7 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1623,8 +1623,10 @@ static int fw_devlink_create_devlink(struct device *con,
> * cycles. So cycle detection isn't necessary and shouldn't be
> * done.
> */
> - if (flags & DL_FLAG_SYNC_STATE_ONLY)
> - return -EAGAIN;
> + if (flags & DL_FLAG_SYNC_STATE_ONLY) {
> + ret = -EAGAIN;
> + goto out;
> + }

If you check a few lines above, you'll notice that to get here sup_dev
== NULL. So, this patch isn't needed. Thanks for reviewing the code
though.

-Saravana