summaryrefslogtreecommitdiff
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-06-27 22:55:27 +0200
commitccfdad2f499e125ce3f567b12492c176c9459927 (patch)
treec7b9abcec91ce28fa7ba3c935914fbcce99c4b3e
parent71394eaf9191a2f8944900d8a738c32cff3c2e5b (diff)
backport: check for failure when allocating ops in genetlink
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