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

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