Blame SOURCES/0016-netlink-return-ENOMEM-when-calloc-fails.patch

4f6fcd
From d0362097e60d227bac4f66a06891ee1d807d2c48 Mon Sep 17 00:00:00 2001
4f6fcd
From: Ivan Vecera <cera@cera.cz>
4f6fcd
Date: Thu, 24 Sep 2020 19:51:47 +0200
4f6fcd
Subject: [PATCH 16/17] netlink: return -ENOMEM when calloc fails
4f6fcd
4f6fcd
Fixes: f2c17e107900 ("netlink: add netlink handler for gfeatures (-k)")
4f6fcd
4f6fcd
Cc: Michal Kubecek <mkubecek@suse.cz>
4f6fcd
Signed-off-by: Ivan Vecera <cera@cera.cz>
4f6fcd
---
4f6fcd
 netlink/features.c | 9 +++++----
4f6fcd
 1 file changed, 5 insertions(+), 4 deletions(-)
4f6fcd
4f6fcd
diff --git a/netlink/features.c b/netlink/features.c
4f6fcd
index 3f1240437350..b2cf57eea660 100644
4f6fcd
--- a/netlink/features.c
4f6fcd
+++ b/netlink/features.c
4f6fcd
@@ -112,16 +112,17 @@ int dump_features(const struct nlattr *const *tb,
4f6fcd
 	unsigned int *feature_flags = NULL;
4f6fcd
 	struct feature_results results;
4f6fcd
 	unsigned int i, j;
4f6fcd
-	int ret;
4f6fcd
+	int ret = 0;
4f6fcd
 
4f6fcd
 	ret = prepare_feature_results(tb, &results);
4f6fcd
 	if (ret < 0)
4f6fcd
 		return -EFAULT;
4f6fcd
 
4f6fcd
-	ret = -ENOMEM;
4f6fcd
 	feature_flags = calloc(results.count, sizeof(feature_flags[0]));
4f6fcd
-	if (!feature_flags)
4f6fcd
+	if (!feature_flags) {
4f6fcd
+		ret = -ENOMEM;
4f6fcd
 		goto out_free;
4f6fcd
+	}
4f6fcd
 
4f6fcd
 	/* map netdev features to legacy flags */
4f6fcd
 	for (i = 0; i < results.count; i++) {
4f6fcd
@@ -184,7 +185,7 @@ int dump_features(const struct nlattr *const *tb,
4f6fcd
 
4f6fcd
 out_free:
4f6fcd
 	free(feature_flags);
4f6fcd
-	return 0;
4f6fcd
+	return ret;
4f6fcd
 }
4f6fcd
 
4f6fcd
 int features_reply_cb(const struct nlmsghdr *nlhdr, void *data)
4f6fcd
-- 
4f6fcd
2.26.2
4f6fcd