* [PATCH] ioctl: only memset non-NULL link settings
@ 2020-08-24 6:46 Hans-Christian Noren Egtvedt
2020-08-27 8:23 ` Michal Kubecek
0 siblings, 1 reply; 3+ messages in thread
From: Hans-Christian Noren Egtvedt @ 2020-08-24 6:46 UTC (permalink / raw)
To: netdev; +Cc: Hans-Christian Noren Egtvedt
In commit bef780467fa ('ioctl: do not pass transceiver value back to
kernel') a regression slipped. If we have a kernel that does not support
the ETHTOOL_xLINKSETTINGS API, then the do_ioctl_glinksettings()
function will return a NULL pointer.
Hence before memset'ing the pointer to zero we must first check it is
valid, as NULL return is perfectly fine when running on old kernels.
Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
---
ethtool.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index c4ad186..8267d6b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2908,8 +2908,10 @@ static int do_sset(struct cmd_context *ctx)
struct ethtool_link_usettings *link_usettings;
link_usettings = do_ioctl_glinksettings(ctx);
- memset(&link_usettings->deprecated, 0,
- sizeof(link_usettings->deprecated));
+ if (link_usettings) {
+ memset(&link_usettings->deprecated, 0,
+ sizeof(link_usettings->deprecated));
+ }
if (link_usettings == NULL)
link_usettings = do_ioctl_gset(ctx);
if (link_usettings == NULL) {
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ioctl: only memset non-NULL link settings
2020-08-24 6:46 [PATCH] ioctl: only memset non-NULL link settings Hans-Christian Noren Egtvedt
@ 2020-08-27 8:23 ` Michal Kubecek
2020-08-27 9:50 ` Hans-Christian Egtvedt (hegtvedt)
0 siblings, 1 reply; 3+ messages in thread
From: Michal Kubecek @ 2020-08-27 8:23 UTC (permalink / raw)
To: Hans-Christian Noren Egtvedt; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]
On Mon, Aug 24, 2020 at 08:46:30AM +0200, Hans-Christian Noren Egtvedt wrote:
> In commit bef780467fa ('ioctl: do not pass transceiver value back to
> kernel') a regression slipped. If we have a kernel that does not support
> the ETHTOOL_xLINKSETTINGS API, then the do_ioctl_glinksettings()
> function will return a NULL pointer.
>
> Hence before memset'ing the pointer to zero we must first check it is
> valid, as NULL return is perfectly fine when running on old kernels.
>
Please add a standard "Fixes:" line here, i.e.
Fixes: bef780467fa7 ("ioctl: do not pass transceiver value back to kernel")
> Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
> ---
> ethtool.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/ethtool.c b/ethtool.c
> index c4ad186..8267d6b 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -2908,8 +2908,10 @@ static int do_sset(struct cmd_context *ctx)
> struct ethtool_link_usettings *link_usettings;
>
> link_usettings = do_ioctl_glinksettings(ctx);
> - memset(&link_usettings->deprecated, 0,
> - sizeof(link_usettings->deprecated));
> + if (link_usettings) {
> + memset(&link_usettings->deprecated, 0,
> + sizeof(link_usettings->deprecated));
> + }
> if (link_usettings == NULL)
> link_usettings = do_ioctl_gset(ctx);
This is correct fix but now we have two if statements with exactly
opposite conditions here; please combine them into one if-else.
Thank you,
Michal
> if (link_usettings == NULL) {
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ioctl: only memset non-NULL link settings
2020-08-27 8:23 ` Michal Kubecek
@ 2020-08-27 9:50 ` Hans-Christian Egtvedt (hegtvedt)
0 siblings, 0 replies; 3+ messages in thread
From: Hans-Christian Egtvedt (hegtvedt) @ 2020-08-27 9:50 UTC (permalink / raw)
To: Michal Kubecek; +Cc: netdev
On 27/08/2020 10:23, Michal Kubecek wrote:
> On Mon, Aug 24, 2020 at 08:46:30AM +0200, Hans-Christian Noren Egtvedt wrote:
>> In commit bef780467fa ('ioctl: do not pass transceiver value back to
>> kernel') a regression slipped. If we have a kernel that does not support
>> the ETHTOOL_xLINKSETTINGS API, then the do_ioctl_glinksettings()
>> function will return a NULL pointer.
>>
>> Hence before memset'ing the pointer to zero we must first check it is
>> valid, as NULL return is perfectly fine when running on old kernels.
>>
>
> Please add a standard "Fixes:" line here, i.e.
>
> Fixes: bef780467fa7 ("ioctl: do not pass transceiver value back to kernel")
>
>> Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
>> ---
>> ethtool.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/ethtool.c b/ethtool.c
>> index c4ad186..8267d6b 100644
>> --- a/ethtool.c
>> +++ b/ethtool.c
>> @@ -2908,8 +2908,10 @@ static int do_sset(struct cmd_context *ctx)
>> struct ethtool_link_usettings *link_usettings;
>>
>> link_usettings = do_ioctl_glinksettings(ctx);
>> - memset(&link_usettings->deprecated, 0,
>> - sizeof(link_usettings->deprecated));
>> + if (link_usettings) {
>> + memset(&link_usettings->deprecated, 0,
>> + sizeof(link_usettings->deprecated));
>> + }
>> if (link_usettings == NULL)
>> link_usettings = do_ioctl_gset(ctx);
>
> This is correct fix but now we have two if statements with exactly
> opposite conditions here; please combine them into one if-else.
Thank you for the review, a v2 will arrive shortly.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-27 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-24 6:46 [PATCH] ioctl: only memset non-NULL link settings Hans-Christian Noren Egtvedt
2020-08-27 8:23 ` Michal Kubecek
2020-08-27 9:50 ` Hans-Christian Egtvedt (hegtvedt)
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.