summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Coelho <luciano.coelho@intel.com>2018-11-01 15:08:17 +0200
committerJohannes Berg <johannes.berg@intel.com>2018-11-05 08:15:37 +0100
commit6f2b0d73e567844a8c8766218c4e34739643b029 (patch)
tree7890a8d11eb10a4c6347f01ac883286f55ac7142
parent74d530b6a5f248521003d2e312bca9dba23cf049 (diff)
backports: check if genl pre_doit and post_doit are set
In the pre_doit and post_doit backports, we set the ops to our backported version, so genetlink itself will always call it. But then we don't check if the actual ops are set before calling them, which causes a call to a NULL pointer. Fix this by checking if the ops are actually set before calling them. Fixes: ff6746638cf1 ("backports: genetlink: update completely") Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--backport/compat/backport-genetlink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
index cc70cd73..71bf45ad 100644
--- a/backport/compat/backport-genetlink.c
+++ b/backport/compat/backport-genetlink.c
@@ -171,7 +171,7 @@ static int backport_pre_doit(__genl_const struct genl_ops *ops,
err = nlmsg_validate(info->nlhdr, GENL_HDRLEN + family->hdrsize,
family->maxattr, ops->policy, extack);
- if (!err)
+ if (!err && family->pre_doit)
err = family->pre_doit(ops, skb, info);
#if LINUX_VERSION_IS_LESS(4,12,0)
@@ -205,7 +205,8 @@ static void backport_post_doit(__genl_const struct genl_ops *ops,
#else
if (1)
#endif
- family->post_doit(ops, skb, info);
+ if (family->post_doit)
+ family->post_doit(ops, skb, info);
#if LINUX_VERSION_IS_LESS(4,12,0)
kfree(__bp_genl_info_userhdr(info));