All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()'
@ 2021-01-24  6:32 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-01-24  6:32 UTC (permalink / raw)
  To: gregkh, rafael, saravanak
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

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@wanadoo.fr>
---
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 we can't find the supplier device from its fwnode, it might be
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()'
@ 2021-01-24  6:32 ` Christophe JAILLET
  0 siblings, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-01-24  6:32 UTC (permalink / raw)
  To: gregkh, rafael, saravanak
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET

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@wanadoo.fr>
---
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 we can't find the supplier device from its fwnode, it might be
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()'
  2021-01-24  6:32 ` Christophe JAILLET
@ 2021-01-24  8:56   ` Saravana Kannan
  -1 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2021-01-24  8:56 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, LKML, kernel-janitors

On Sat, Jan 23, 2021 at 10:32 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> 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@wanadoo.fr>
> ---
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()'
@ 2021-01-24  8:56   ` Saravana Kannan
  0 siblings, 0 replies; 4+ messages in thread
From: Saravana Kannan @ 2021-01-24  8:56 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, LKML, kernel-janitors

On Sat, Jan 23, 2021 at 10:32 PM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> 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@wanadoo.fr>
> ---
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-24  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24  6:32 [PATCH] driver core: Fix a reource leak in 'fw_devlink_create_devlink()' Christophe JAILLET
2021-01-24  6:32 ` Christophe JAILLET
2021-01-24  8:56 ` Saravana Kannan
2021-01-24  8:56   ` Saravana Kannan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.