netlink: fix allocation failure handling in dump_features()
Subsystems (2)
PATCH 1/1 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.
--- netlink/features.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
netlink/features.c +1 -4
@@ -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 ; }
Signature · 1 line
2.28.0
This patch was applied to ethtool/ethtool.git (refs/heads/master):
Hello:
This patch was applied to ethtool/ethtool.git (refs/heads/master):
Quoted 10 lines · On Wed, 14 Oct 2020 18:49:52 +0200 (CEST) you wrote:
On allocation failure,
dump_features()would set ret to-ENOMEMbut then return 0 anyway. As there is nothing to free in this case anyway, the easiest fix is to simply return-ENOMEMrather than jumping toout_freelabel - 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 <[email protected]>Signed-off-by Michal Kubecek <[email protected]>[...]
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