From patchwork Thu Nov 1 13:08:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 10663953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B89614E2 for ; Thu, 1 Nov 2018 13:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0904E28911 for ; Thu, 1 Nov 2018 13:08:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB9B328908; Thu, 1 Nov 2018 13:08:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A5C928908 for ; Thu, 1 Nov 2018 13:08:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728423AbeKAWLS (ORCPT ); Thu, 1 Nov 2018 18:11:18 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:33756 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727644AbeKAWLS (ORCPT ); Thu, 1 Nov 2018 18:11:18 -0400 Received: from 91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.91) (envelope-from ) id 1gIChx-0006kD-Ma; Thu, 01 Nov 2018 15:08:22 +0200 From: Luca Coelho To: backports@vger.kernel.org Cc: Luca Coelho Date: Thu, 1 Nov 2018 15:08:17 +0200 Message-Id: <20181101130817.10211-1-luca@coelho.fi> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [PATCH] backports: check if genl pre_doit and post_doit are set Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luca Coelho 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 --- 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));