diff options
author | Michal Kubecek <mkubecek@suse.cz> | 2020-10-14 18:49:52 +0200 |
---|---|---|
committer | Michal Kubecek <mkubecek@suse.cz> | 2020-10-15 18:39:45 +0200 |
commit | 09c67a720a074d33f5832f03bee76180d3b24aa7 (patch) | |
tree | e0a65b24ac3297f65f71ca8a36ca37eeeeb8f0a1 | |
parent | aef58b7ad1df812b49ef074041837a2108c62e2e (diff) | |
download | ethtool-09c67a720a074d33f5832f03bee76180d3b24aa7.tar.gz |
netlink: fix allocation failure handling in dump_features()
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>
-rw-r--r-- | netlink/features.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/netlink/features.c b/netlink/features.c index 3f12404..2a0899e 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; } |