* [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink()
@ 2023-07-17 18:26 Christophe JAILLET
2023-07-17 18:57 ` Saravana Kannan
0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2023-07-17 18:26 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Saravana Kannan
Cc: linux-kernel, kernel-janitors, Christophe JAILLET
All error handling paths go to 'out', except this one. Be consistent and
also branch to 'out' here.
Fixes: 74c782cff77b ("driver core: fw_devlink: Handle suppliers that don't use driver core")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
/!\ Speculative /!\
This patch is based on analysis of the surrounding code and should be
reviewed with care !
If the patch is wrong, maybe a comment in the code could explain why.
/!\ Speculative /!\
---
drivers/base/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3dff5037943e..854c1fab742c 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2107,7 +2107,8 @@ static int fw_devlink_create_devlink(struct device *con,
fwnode_ancestor_init_without_drv(sup_handle)) {
dev_dbg(con, "Not linking %pfwf - might never become dev\n",
sup_handle);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
ret = -EAGAIN;
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink()
2023-07-17 18:26 [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink() Christophe JAILLET
@ 2023-07-17 18:57 ` Saravana Kannan
2023-07-17 19:32 ` Christophe JAILLET
2023-07-18 6:12 ` Dan Carpenter
0 siblings, 2 replies; 4+ messages in thread
From: Saravana Kannan @ 2023-07-17 18:57 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, kernel-janitors
On Mon, Jul 17, 2023 at 11:26 AM Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> All error handling paths go to 'out', except this one. Be consistent and
> also branch to 'out' here.
>
> Fixes: 74c782cff77b ("driver core: fw_devlink: Handle suppliers that don't use driver core")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> /!\ Speculative /!\
>
> This patch is based on analysis of the surrounding code and should be
> reviewed with care !
>
> If the patch is wrong, maybe a comment in the code could explain why.
>
> /!\ Speculative /!\
Looks okay to me, but I'd rather not much around the code for a
subjective preference. The existing code also avoids the pointless
put_device() and personally is easier to read (ok, nothing more of
relevance is done after this return) than trying to follow the
execution to the out and then realizing the put_device() is a NOP,
etc. It also means future changes to "out" will need to accommodate
for this path that doesn't really need the "out" path.
-Saravana
> ---
> drivers/base/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 3dff5037943e..854c1fab742c 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -2107,7 +2107,8 @@ static int fw_devlink_create_devlink(struct device *con,
> fwnode_ancestor_init_without_drv(sup_handle)) {
> dev_dbg(con, "Not linking %pfwf - might never become dev\n",
> sup_handle);
> - return -EINVAL;
> + ret = -EINVAL;
> + goto out;
> }
>
> ret = -EAGAIN;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink()
2023-07-17 18:57 ` Saravana Kannan
@ 2023-07-17 19:32 ` Christophe JAILLET
2023-07-18 6:12 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Christophe JAILLET @ 2023-07-17 19:32 UTC (permalink / raw)
To: Saravana Kannan
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel, kernel-janitors
Le 17/07/2023 à 20:57, Saravana Kannan a écrit :
> On Mon, Jul 17, 2023 at 11:26 AM Christophe JAILLET
> <christophe.jaillet@wanadoo.fr> wrote:
>>
>> All error handling paths go to 'out', except this one. Be consistent and
>> also branch to 'out' here.
>>
>> Fixes: 74c782cff77b ("driver core: fw_devlink: Handle suppliers that don't use driver core")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> /!\ Speculative /!\
>>
>> This patch is based on analysis of the surrounding code and should be
>> reviewed with care !
>>
>> If the patch is wrong, maybe a comment in the code could explain why.
>>
>> /!\ Speculative /!\
>
> Looks okay to me, but I'd rather not much around the code for a
> subjective preference. The existing code also avoids the pointless
> put_device() and personally is easier to read (ok, nothing more of
> relevance is done after this return) than trying to follow the
> execution to the out and then realizing the put_device() is a NOP,
> etc. It also means future changes to "out" will need to accommodate
> for this path that doesn't really need the "out" path.
>
> -Saravana
Agreed,
I didn't realized that this code was executed only if "if (sup_dev)"
fails, so only if sup_dev is NULL.
Sorry for the noise.
CJ
>
>> ---
>> drivers/base/core.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 3dff5037943e..854c1fab742c 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -2107,7 +2107,8 @@ static int fw_devlink_create_devlink(struct device *con,
>> fwnode_ancestor_init_without_drv(sup_handle)) {
>> dev_dbg(con, "Not linking %pfwf - might never become dev\n",
>> sup_handle);
>> - return -EINVAL;
>> + ret = -EINVAL;
>> + goto out;
>> }
>>
>> ret = -EAGAIN;
>> --
>> 2.34.1
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink()
2023-07-17 18:57 ` Saravana Kannan
2023-07-17 19:32 ` Christophe JAILLET
@ 2023-07-18 6:12 ` Dan Carpenter
1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-07-18 6:12 UTC (permalink / raw)
To: Saravana Kannan
Cc: Christophe JAILLET, Greg Kroah-Hartman, Rafael J. Wysocki,
linux-kernel, kernel-janitors
On Mon, Jul 17, 2023 at 11:57:51AM -0700, Saravana Kannan wrote:
> > ---
> > drivers/base/core.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > index 3dff5037943e..854c1fab742c 100644
> > --- a/drivers/base/core.c
> > +++ b/drivers/base/core.c
> > @@ -2107,7 +2107,8 @@ static int fw_devlink_create_devlink(struct device *con,
> > fwnode_ancestor_init_without_drv(sup_handle)) {
> > dev_dbg(con, "Not linking %pfwf - might never become dev\n",
> > sup_handle);
> > - return -EINVAL;
> > + ret = -EINVAL;
> > + goto out;
> > }
> >
> > ret = -EAGAIN;
It would have been more obvious that put_device() is a no-op if this
ret = -EAGAIN were changed to "return -EAGAIN;". That would probably
silence some sort of static checker warning...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-18 6:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17 18:26 [PATCH] driver core: Fix an error handling path in fw_devlink_create_devlink() Christophe JAILLET
2023-07-17 18:57 ` Saravana Kannan
2023-07-17 19:32 ` Christophe JAILLET
2023-07-18 6:12 ` Dan Carpenter
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®