From patchwork Wed Apr 2 07:55:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeseok Youn X-Patchwork-Id: 3927141 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A51E79F2F7 for ; Wed, 2 Apr 2014 07:56:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1FBE2024D for ; Wed, 2 Apr 2014 07:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 15A532022F for ; Wed, 2 Apr 2014 07:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757967AbaDBHzg (ORCPT ); Wed, 2 Apr 2014 03:55:36 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:40843 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753357AbaDBHzf (ORCPT ); Wed, 2 Apr 2014 03:55:35 -0400 Received: by mail-pa0-f47.google.com with SMTP id lj1so11125702pab.34 for ; Wed, 02 Apr 2014 00:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=IulgoP2q+nDgG5ry1aco3/5x+6ezozr0Xoufb6aFEOw=; b=XEBDMceUzZp6Lhxh+K2r5V+Pt7upLeQXkjjrEbb34liL/zt/jY2Ds1ZnAY1CTGzgXF yr99Ki4zN3A08EPEJ9m5OVHeaOCWWo0C3cjZtLxsWT0l6LyCB9wECtcOcGvfEHUAKAGr 0pU4cRFvRwQ3n/WRqyvkOFXySlEL+wLu4JGuEXumx1SJFgaT56t4lv0e53naA9gTYSUy 92IQJBkz+DnVgL5vtnp7WT1qVHZMnM5g3NvEeNGhgjqpGZQdiZ3MGt0hXs5FXH7XvkP9 c1YAcy61Ojhhx1zQIQu2NAzQhq+aywM109MhjLYQjgeXKEbFs/C8GZM984ftse9QIrDC ZBfA== X-Received: by 10.68.196.226 with SMTP id ip2mr36083604pbc.106.1396425334425; Wed, 02 Apr 2014 00:55:34 -0700 (PDT) Received: from daeseok-laptop.cloud.net ([121.50.21.19]) by mx.google.com with ESMTPSA id tf10sm2559701pbc.70.2014.04.02.00.55.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Apr 2014 00:55:33 -0700 (PDT) From: Daeseok Youn To: davem@davemloft.net, lauro.venancio@openbossa.org Cc: aloisio.almeida@openbossa.org, sameo@linux.intel.com, linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] nfc: fix NULL pointer dereference Date: Wed, 02 Apr 2014 16:55:30 +0900 Message-ID: <20540404.Au0OUqzobS@daeseok-laptop.cloud.net> User-Agent: KMail/4.8.5 (Linux/3.2.0-58-generic; KDE/4.8.5; x86_64; ; ) MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 dev is NULL when nfc_get_device() is failed but dev is used for handling error. coccicheck says: net/nfc/netlink.c:1092:21-24: ERROR: dev is NULL but dereferenced. Signed-off-by: Daeseok Youn --- net/nfc/netlink.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 43cb1c1..b2ad570 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1026,10 +1026,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);