aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Coelho <luciano.coelho@intel.com>2019-04-02 16:08:23 +0300
committerHauke Mehrtens <hauke@hauke-m.de>2019-07-06 17:13:29 +0200
commitcb1dd1a3b081c188e248986c07459ad6ac049aa5 (patch)
tree265d8aadd261da9ab8bf251f89aeeac9cfce0b6f
parent42b1ad9c63d82fef5ea6f4292fd713fa2d62f530 (diff)
downloadbackports-linux-5.1.y.tar.gz
backport: check for failure when allocating ops in genetlinkv5.1.16-1linux-5.1.y
Upstream commit: ccfdad2f499e125ce3f567b12492c176c9459927 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>
-rw-r--r--backport/compat/backport-genetlink.c4
1 files changed, 4 insertions, 0 deletions
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