* [PATCH] net: sxgbe: fix return value of __setup handler
@ 2022-02-24 3:35 Randy Dunlap
2022-02-25 5:43 ` Jakub Kicinski
2022-02-25 17:21 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Randy Dunlap @ 2022-02-24 3:35 UTC (permalink / raw)
To: netdev
Cc: patches, Randy Dunlap, Igor Zhbanov, Siva Reddy, Girish K S,
Byungho An, David S. Miller, Jakub Kicinski
__setup() handlers should return 1 on success, i.e., the parameter
has been handled. A return of 0 causes the "option=value" string to be
added to init's environment strings, polluting it.
Fixes: acc18c147b22 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
Cc: Siva Reddy <siva.kallam@samsung.com>
Cc: Girish K S <ks.giri@samsung.com>
Cc: Byungho An <bh74.an@samsung.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- linux-next-20220223.orig/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ linux-next-20220223/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -2285,18 +2285,18 @@ static int __init sxgbe_cmdline_opt(char
char *opt;
if (!str || !*str)
- return -EINVAL;
+ return 1;
while ((opt = strsep(&str, ",")) != NULL) {
if (!strncmp(opt, "eee_timer:", 10)) {
if (kstrtoint(opt + 10, 0, &eee_timer))
goto err;
}
}
- return 0;
+ return 1;
err:
pr_err("%s: ERROR broken module parameter conversion\n", __func__);
- return -EINVAL;
+ return 1;
}
__setup("sxgbeeth=", sxgbe_cmdline_opt);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: sxgbe: fix return value of __setup handler
2022-02-24 3:35 [PATCH] net: sxgbe: fix return value of __setup handler Randy Dunlap
@ 2022-02-25 5:43 ` Jakub Kicinski
2022-02-25 7:30 ` Randy Dunlap
2022-02-25 17:21 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2022-02-25 5:43 UTC (permalink / raw)
To: Randy Dunlap
Cc: netdev, patches, Igor Zhbanov, Siva Reddy, Girish K S, Byungho An,
David S. Miller
On Wed, 23 Feb 2022 19:35:28 -0800 Randy Dunlap wrote:
> __setup() handlers should return 1 on success, i.e., the parameter
> has been handled. A return of 0 causes the "option=value" string to be
> added to init's environment strings, polluting it.
Meaning early_param_on_off() also returns the wrong thing?
Or that's different?
> Fixes: acc18c147b22 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
> Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
> Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
>
> --- linux-next-20220223.orig/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
> +++ linux-next-20220223/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
> @@ -2285,18 +2285,18 @@ static int __init sxgbe_cmdline_opt(char
> char *opt;
>
> if (!str || !*str)
> - return -EINVAL;
> + return 1;
> while ((opt = strsep(&str, ",")) != NULL) {
> if (!strncmp(opt, "eee_timer:", 10)) {
> if (kstrtoint(opt + 10, 0, &eee_timer))
> goto err;
> }
> }
> - return 0;
> + return 1;
>
> err:
> pr_err("%s: ERROR broken module parameter conversion\n", __func__);
> - return -EINVAL;
> + return 1;
> }
>
> __setup("sxgbeeth=", sxgbe_cmdline_opt);
Was the option of making __setup() return void considered?
Sounds like we always want to return 1 so what's the point?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: sxgbe: fix return value of __setup handler
2022-02-25 5:43 ` Jakub Kicinski
@ 2022-02-25 7:30 ` Randy Dunlap
2022-02-25 15:59 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2022-02-25 7:30 UTC (permalink / raw)
To: Jakub Kicinski
Cc: netdev, patches, Igor Zhbanov, Siva Reddy, Girish K S, Byungho An,
David S. Miller
On 2/24/22 21:43, Jakub Kicinski wrote:
> On Wed, 23 Feb 2022 19:35:28 -0800 Randy Dunlap wrote:
>> __setup() handlers should return 1 on success, i.e., the parameter
>> has been handled. A return of 0 causes the "option=value" string to be
>> added to init's environment strings, polluting it.
>
> Meaning early_param_on_off() also returns the wrong thing?
> Or that's different?
early_param() and its varieties are different -- 0 for success, else error.
>> Fixes: acc18c147b22 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
>> Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
>> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
>> Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
>> Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
>>
>> --- linux-next-20220223.orig/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
>> +++ linux-next-20220223/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
>> @@ -2285,18 +2285,18 @@ static int __init sxgbe_cmdline_opt(char
>> char *opt;
>>
>> if (!str || !*str)
>> - return -EINVAL;
>> + return 1;
>> while ((opt = strsep(&str, ",")) != NULL) {
>> if (!strncmp(opt, "eee_timer:", 10)) {
>> if (kstrtoint(opt + 10, 0, &eee_timer))
>> goto err;
>> }
>> }
>> - return 0;
>> + return 1;
>>
>> err:
>> pr_err("%s: ERROR broken module parameter conversion\n", __func__);
>> - return -EINVAL;
>> + return 1;
>> }
>>
>> __setup("sxgbeeth=", sxgbe_cmdline_opt);
>
> Was the option of making __setup() return void considered?
> Sounds like we always want to return 1 so what's the point?
Well, AFAIK __setup() has been around forever (at least 22 years), so No,
I don't think anyone has considered making it void.
Returning 1 or 0 gives kernel parameter writers the option of how error
input is handled, although 0 is usually wrong. :)
--
~Randy
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: sxgbe: fix return value of __setup handler
2022-02-25 7:30 ` Randy Dunlap
@ 2022-02-25 15:59 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2022-02-25 15:59 UTC (permalink / raw)
To: Randy Dunlap
Cc: netdev, patches, Igor Zhbanov, Siva Reddy, Girish K S, Byungho An,
David S. Miller
On Thu, 24 Feb 2022 23:30:42 -0800 Randy Dunlap wrote:
> On 2/24/22 21:43, Jakub Kicinski wrote:
> > On Wed, 23 Feb 2022 19:35:28 -0800 Randy Dunlap wrote:
> >> __setup() handlers should return 1 on success, i.e., the parameter
> >> has been handled. A return of 0 causes the "option=value" string to be
> >> added to init's environment strings, polluting it.
> >
> > Meaning early_param_on_off() also returns the wrong thing?
> > Or that's different?
>
> early_param() and its varieties are different -- 0 for success, else error.
Making it an even stronger contender for the worst API ever award ;)
> >> Fixes: acc18c147b22 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
> >> Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
> >> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> >> Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
> >> Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
> >>
> >> --- linux-next-20220223.orig/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
> >> +++ linux-next-20220223/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
> >> @@ -2285,18 +2285,18 @@ static int __init sxgbe_cmdline_opt(char
> >> char *opt;
> >>
> >> if (!str || !*str)
> >> - return -EINVAL;
> >> + return 1;
> >> while ((opt = strsep(&str, ",")) != NULL) {
> >> if (!strncmp(opt, "eee_timer:", 10)) {
> >> if (kstrtoint(opt + 10, 0, &eee_timer))
> >> goto err;
> >> }
> >> }
> >> - return 0;
> >> + return 1;
> >>
> >> err:
> >> pr_err("%s: ERROR broken module parameter conversion\n", __func__);
> >> - return -EINVAL;
> >> + return 1;
> >> }
> >>
> >> __setup("sxgbeeth=", sxgbe_cmdline_opt);
> >
> > Was the option of making __setup() return void considered?
> > Sounds like we always want to return 1 so what's the point?
>
> Well, AFAIK __setup() has been around forever (at least 22 years), so No,
> I don't think anyone has considered making it void.
>
> Returning 1 or 0 gives kernel parameter writers the option of how error
> input is handled, although 0 is usually wrong. :)
Yeah, well, we've been making bus ->remove() functions void IIUC
so why not this. That's separate from fixing the current incorrect
uses tho, so let me apply both of the netdev fixes, thank you!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: sxgbe: fix return value of __setup handler
2022-02-24 3:35 [PATCH] net: sxgbe: fix return value of __setup handler Randy Dunlap
2022-02-25 5:43 ` Jakub Kicinski
@ 2022-02-25 17:21 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-25 17:21 UTC (permalink / raw)
To: Randy Dunlap
Cc: netdev, patches, i.zhbanov, siva.kallam, ks.giri, bh74.an, davem,
kuba
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 23 Feb 2022 19:35:28 -0800 you wrote:
> __setup() handlers should return 1 on success, i.e., the parameter
> has been handled. A return of 0 causes the "option=value" string to be
> added to init's environment strings, polluting it.
>
> Fixes: acc18c147b22 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
> Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
> Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
> Cc: Siva Reddy <siva.kallam@samsung.com>
> Cc: Girish K S <ks.giri@samsung.com>
> Cc: Byungho An <bh74.an@samsung.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- net: sxgbe: fix return value of __setup handler
https://git.kernel.org/netdev/net/c/50e06ddceeea
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-25 17:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-24 3:35 [PATCH] net: sxgbe: fix return value of __setup handler Randy Dunlap
2022-02-25 5:43 ` Jakub Kicinski
2022-02-25 7:30 ` Randy Dunlap
2022-02-25 15:59 ` Jakub Kicinski
2022-02-25 17:21 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).