Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH ethtool 1/2] fix memory leaks in do_sfeatures()
@ 2020-09-25 7:05 Ivan Vecera
2020-09-25 7:05 ` [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary() Ivan Vecera
2020-09-28 15:37 ` [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Michal Kubecek
0 siblings, 2 replies; 4+ messages in thread
From: Ivan Vecera @ 2020-09-25 7:05 UTC (permalink / raw)
To: netdev; +Cc: Michal Kubecek
Memory blocks referenced by new_state and old_state are never freed.
For efeatures there is no need to check pointer as free() can be called
with NULL parameter.
Fixes: 6042804cf6ec ("Change -k/-K options to use ETHTOOL_{G,S}FEATURES")
Cc: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
ethtool.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index ab9b4577cbce..f2d568722272 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2392,9 +2392,10 @@ static int do_sfeatures(struct cmd_context *ctx)
int any_changed = 0, any_mismatch = 0;
u32 off_flags_wanted = 0;
u32 off_flags_mask = 0;
- struct ethtool_sfeatures *efeatures;
+ struct ethtool_sfeatures *efeatures = NULL;
+ struct feature_state *old_state = NULL;
+ struct feature_state *new_state = NULL;
struct cmdline_info *cmdline_features;
- struct feature_state *old_state, *new_state;
struct ethtool_value eval;
unsigned int i, j;
int err, rc;
@@ -2418,8 +2419,6 @@ static int do_sfeatures(struct cmd_context *ctx)
memset(efeatures->features, 0,
FEATURE_BITS_TO_BLOCKS(defs->n_features) *
sizeof(efeatures->features[0]));
- } else {
- efeatures = NULL;
}
/* Generate cmdline_info for legacy flags and kernel-named
@@ -2578,9 +2577,11 @@ static int do_sfeatures(struct cmd_context *ctx)
rc = 0;
err:
+ free(new_state);
+ free(old_state);
free(defs);
- if (efeatures)
- free(efeatures);
+ free(efeatures);
+
return rc;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary()
2020-09-25 7:05 [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Ivan Vecera
@ 2020-09-25 7:05 ` Ivan Vecera
2020-09-28 15:38 ` Michal Kubecek
2020-09-28 15:37 ` [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Michal Kubecek
1 sibling, 1 reply; 4+ messages in thread
From: Ivan Vecera @ 2020-09-25 7:05 UTC (permalink / raw)
To: netdev; +Cc: Michal Kubecek
Fixes: bdfffab54933 ("netlink: message format descriptions for rtnetlink")
Cc: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
netlink/prettymsg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/netlink/prettymsg.c b/netlink/prettymsg.c
index 9e62bebe615e..f992dcaf071f 100644
--- a/netlink/prettymsg.c
+++ b/netlink/prettymsg.c
@@ -202,7 +202,7 @@ static void rtm_link_summary(const struct ifinfomsg *ifinfo)
printf(" ifindex=%d", ifinfo->ifi_index);
if (ifinfo->ifi_flags)
printf(" flags=0x%x", ifinfo->ifi_flags);
- if (ifinfo->ifi_flags)
+ if (ifinfo->ifi_change)
printf(" change=0x%x", ifinfo->ifi_change);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH ethtool 1/2] fix memory leaks in do_sfeatures()
2020-09-25 7:05 [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Ivan Vecera
2020-09-25 7:05 ` [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary() Ivan Vecera
@ 2020-09-28 15:37 ` Michal Kubecek
1 sibling, 0 replies; 4+ messages in thread
From: Michal Kubecek @ 2020-09-28 15:37 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 450 bytes --]
On Fri, Sep 25, 2020 at 09:05:26AM +0200, Ivan Vecera wrote:
> Memory blocks referenced by new_state and old_state are never freed.
> For efeatures there is no need to check pointer as free() can be called
> with NULL parameter.
>
> Fixes: 6042804cf6ec ("Change -k/-K options to use ETHTOOL_{G,S}FEATURES")
>
> Cc: Michal Kubecek <mkubecek@suse.cz>
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
Applied, thank you.
Michal
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary()
2020-09-25 7:05 ` [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary() Ivan Vecera
@ 2020-09-28 15:38 ` Michal Kubecek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Kubecek @ 2020-09-28 15:38 UTC (permalink / raw)
To: Ivan Vecera; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 869 bytes --]
On Fri, Sep 25, 2020 at 09:05:27AM +0200, Ivan Vecera wrote:
> Fixes: bdfffab54933 ("netlink: message format descriptions for rtnetlink")
>
> Cc: Michal Kubecek <mkubecek@suse.cz>
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
Applied, thank you.
Michal
> netlink/prettymsg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/netlink/prettymsg.c b/netlink/prettymsg.c
> index 9e62bebe615e..f992dcaf071f 100644
> --- a/netlink/prettymsg.c
> +++ b/netlink/prettymsg.c
> @@ -202,7 +202,7 @@ static void rtm_link_summary(const struct ifinfomsg *ifinfo)
> printf(" ifindex=%d", ifinfo->ifi_index);
> if (ifinfo->ifi_flags)
> printf(" flags=0x%x", ifinfo->ifi_flags);
> - if (ifinfo->ifi_flags)
> + if (ifinfo->ifi_change)
> printf(" change=0x%x", ifinfo->ifi_change);
> }
>
> --
> 2.26.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-28 15:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25 7:05 [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Ivan Vecera
2020-09-25 7:05 ` [PATCH ethtool 2/2] netlink: fix copy-paste error in rtm_link_summary() Ivan Vecera
2020-09-28 15:38 ` Michal Kubecek
2020-09-28 15:37 ` [PATCH ethtool 1/2] fix memory leaks in do_sfeatures() Michal Kubecek
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).