[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-backports
Subject: [PATCH 03/18] backport: check for failure when allocating ops in genetlink
From: Hauke Mehrtens <hauke () hauke-m ! de>
Date: 2019-07-01 21:48:58
Message-ID: 20190701214914.8066-4-hauke () hauke-m ! de
[Download RAW message or body]
From: Luca Coelho <luciano.coelho@intel.com>
We were not checking if the allocation failed in
backport_genl_register_family(), which could lead to NULL pointer
dereferences later. Fix that.
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
backport/compat/backport-genetlink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
index 885f1756..16971ec3 100644
--- a/backport/compat/backport-genetlink.c
+++ b/backport/compat/backport-genetlink.c
@@ -220,7 +220,11 @@ int backport_genl_register_family(struct genl_family *family)
/* we append one entry to the ops to find our family pointer ... */
ops = kzalloc(sizeof(*ops) * (family->n_ops + 1), GFP_KERNEL);
+ if (!ops)
+ return -ENOMEM;
+
memcpy(ops, family->ops, sizeof(*ops) * family->n_ops);
+
/*
* Remove policy to skip validation as the struct nla_policy
* memory layout isn't compatible with the old version
--
2.20.1
--
To unsubscribe from this list: send the line "unsubscribe backports" in
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic