From patchwork Sat Oct 17 09:32:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 7421911 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CBA379F1D5 for ; Sat, 17 Oct 2015 09:44:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C38020570 for ; Sat, 17 Oct 2015 09:44:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2526C20571 for ; Sat, 17 Oct 2015 09:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbbJQJoI (ORCPT ); Sat, 17 Oct 2015 05:44:08 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:9459 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbbJQJn2 (ORCPT ); Sat, 17 Oct 2015 05:43:28 -0400 X-IronPort-AV: E=Sophos;i="5.17,692,1437429600"; d="scan'208";a="150856381" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES128-SHA256; 17 Oct 2015 11:43:24 +0200 From: Julia Lawall To: Lauro Ramos Venancio Cc: kernel-janitors@vger.kernel.org, Aloisio Almeida Jr , Samuel Ortiz , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] NFC: delete null dereference Date: Sat, 17 Oct 2015 11:32:19 +0200 Message-Id: <1445074340-21955-2-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445074340-21955-1-git-send-email-Julia.Lawall@lip6.fr> References: <1445074340-21955-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The exit label performs device_unlock(&dev->dev);, which will fail when dev is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so just exit the function immediately. Problem found using scripts/coccinelle/null/deref_null.cocci Signed-off-by: Julia Lawall --- net/nfc/netlink.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 853172c..f040532 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1109,10 +1109,8 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); dev = nfc_get_device(idx); - if (!dev) { - rc = -ENODEV; - goto exit; - } + if (!dev) + return -ENODEV; device_lock(&dev->dev);