netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ethtool] netlink: fix allocation failure handling in dump_features()
@ 2020-10-14 16:49 Michal Kubecek
  2020-10-15 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kubecek @ 2020-10-14 16:49 UTC (permalink / raw)
  To: netdev; +Cc: ivecera

On allocation failure, dump_features() would set ret to -ENOMEM but then
return 0 anyway. As there is nothing to free in this case anyway, the
easiest fix is to simply return -ENOMEM rather than jumping to out_free
label - which can be dropped as well as this was its only use.

Fixes: f2c17e107900 ("netlink: add netlink handler for gfeatures (-k)")
Reported-by: Ivan Vecera <ivecera@redhat.com>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 netlink/features.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/netlink/features.c b/netlink/features.c
index 3f1240437350..2a0899e6eb04 100644
--- a/netlink/features.c
+++ b/netlink/features.c
@@ -117,11 +117,9 @@ int dump_features(const struct nlattr *const *tb,
 	ret = prepare_feature_results(tb, &results);
 	if (ret < 0)
 		return -EFAULT;
-
-	ret = -ENOMEM;
 	feature_flags = calloc(results.count, sizeof(feature_flags[0]));
 	if (!feature_flags)
-		goto out_free;
+		return -ENOMEM;
 
 	/* map netdev features to legacy flags */
 	for (i = 0; i < results.count; i++) {
@@ -182,7 +180,6 @@ int dump_features(const struct nlattr *const *tb,
 		dump_feature(&results, NULL, NULL, i, name, "");
 	}
 
-out_free:
 	free(feature_flags);
 	return 0;
 }
-- 
2.28.0


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

* Re: [PATCH ethtool] netlink: fix allocation failure handling in dump_features()
  2020-10-14 16:49 [PATCH ethtool] netlink: fix allocation failure handling in dump_features() Michal Kubecek
@ 2020-10-15 18:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-10-15 18:50 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: netdev, ivecera

Hello:

This patch was applied to ethtool/ethtool.git (refs/heads/master):

On Wed, 14 Oct 2020 18:49:52 +0200 (CEST) you wrote:
> On allocation failure, dump_features() would set ret to -ENOMEM but then
> return 0 anyway. As there is nothing to free in this case anyway, the
> easiest fix is to simply return -ENOMEM rather than jumping to out_free
> label - which can be dropped as well as this was its only use.
> 
> Fixes: f2c17e107900 ("netlink: add netlink handler for gfeatures (-k)")
> Reported-by: Ivan Vecera <ivecera@redhat.com>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
> 
> [...]

Here is the summary with links:
  - [ethtool] netlink: fix allocation failure handling in dump_features()
    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=09c67a720a07

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] 2+ messages in thread

end of thread, other threads:[~2020-10-15 18:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 16:49 [PATCH ethtool] netlink: fix allocation failure handling in dump_features() Michal Kubecek
2020-10-15 18:50 ` 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).