Backports Archive mirror
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: backports@vger.kernel.org
Cc: Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH] backports: check if genl pre_doit and post_doit are set
Date: Thu,  1 Nov 2018 15:08:17 +0200	[thread overview]
Message-ID: <20181101130817.10211-1-luca@coelho.fi> (raw)

From: Luca Coelho <luciano.coelho@intel.com>

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>
---
 backport/compat/backport-genetlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/backport/compat/backport-genetlink.c b/backport/compat/backport-genetlink.c
index cc70cd73d0c0..71bf45adf88d 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));
-- 
2.19.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

                 reply	other threads:[~2018-11-01 13:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181101130817.10211-1-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=backports@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).