Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp539459imu; Tue, 27 Nov 2018 02:33:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/XE7Q5CUVfB/f2AoksWIcfnfgC0OBYv0ejgd8L2Jd/WHRUgRbEpH1R9w/jgy4X0nexZjAkg X-Received: by 2002:a17:902:f44:: with SMTP id 62mr29776138ply.38.1543314832703; Tue, 27 Nov 2018 02:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543314832; cv=none; d=google.com; s=arc-20160816; b=U8ONHG7HXv4EjoKc4B9CiLRvJRnE8SiThxVAtQal1Qpv1WQx9J0zOUaiS1ImwybkyX yavM5/7aXmF6Mfw2iiSiPWi3kj3DbNSTJsl0nyQGBqY4qv95U8ucwmEzQN9AmxmMlfas gQL7SSC3fa6LGMVGDaUcnrtIn/qkKcT+1RV2/FHAf6lQdI285cyJOj7frmjP5luTnWMY Eni4LaDgb/e2q/lH5WoRZcCrnP4WlcAp0LGztHJfOAT93Jxzx46HWMBBR/T0ZSWQc9Ka vYIWgOwepimUIBT5Ki+qe9vSiNlYTvSj6HxkUEFRdO8/LSIQISMxEl+jO/crP7iW52e2 HU9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=i2bcApeV8atCnz4/Q75l4r8++FCD2b8hoWXfmw7d/fg=; b=jzOgdwGHt8UpjV4gyIlIexMf/H967fvHVQgvgX3afrmBt/hETID9ZBeshOVn0R66HN HwJuHjFdt30enywuWm2v34Wg9PcHlxdcEZUn/Oo0FrWDRxuPosiJubhIjzFTPA9C1v/c JolPk88T+HAHdEJJfEXJUqVpFEeXrgfdMYGdCs3++Y8rXGlv3NwOWtlFdTEbJ9nUSV+3 k0Q5c4mL3HPectcOyN2cwD5h4tg9P2wCFO6/CEJT2SD9q+0ismX/oa7w2HSQlcX3GH5V oWbDEVIsMbY48zk/1CMeevfgopI9OrPwmHSO97kfWpHMywdMbVZ16Oimgqlyd5TyDBSj 0f0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=X4vl2QUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si3743310pfw.66.2018.11.27.02.33.37; Tue, 27 Nov 2018 02:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=X4vl2QUM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729318AbeK0SwR (ORCPT + 99 others); Tue, 27 Nov 2018 13:52:17 -0500 Received: from m12-11.163.com ([220.181.12.11]:51536 "EHLO m12-11.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728977AbeK0SwQ (ORCPT ); Tue, 27 Nov 2018 13:52:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=i2bcApeV8atCnz4/Q7 5l4r8++FCD2b8hoWXfmw7d/fg=; b=X4vl2QUMuSk7R134sT6PcuVYTTYghdSNI2 Fqj7PHHEX3CIA32bRMRIke2pOStDAr8xh1pSD8wr8MyrXv7+v5z2yEL2aH7ji00M DGZLqwkksY4XxjJN6z4pH7M1QM1PGDkFXELSOLq8b13KWmDgwxaQE7HSQnDnaBp5 JlhLe+WnU= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp7 (Coremail) with SMTP id C8CowAC3GPw8+PxboYqRCA--.739S3; Tue, 27 Nov 2018 15:54:49 +0800 (CST) From: Pan Bian To: Samuel Ortiz , "David S. Miller" Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] NFC: netlink: remove unexpected nfc_put_device Date: Tue, 27 Nov 2018 15:54:35 +0800 Message-Id: <1543305275-23051-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: C8CowAC3GPw8+PxboYqRCA--.739S3 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfJw1rJrW5JrWUKr17Wrg_yoWDArgEyw 1rtr48Wrs5X3s3JF42kr4UAF92kF42gF4xG3WxKr4rAa45Xay5ZFWkAw4fAr17uw43CFW7 X3WkKFWkJry7XjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0oUDJUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/1tbiVAIMclUMGLObWgAAsb Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The functions nfc_genl_llc_set_params and nfc_genl_llc_sdreq drops the reference to dev via nfc_put_device on the error branch that no local device is found. However, the error handling block reads dev's field and then put dev again. This may result in use-after-free bugs. The patch removes the unexpected call to nfc_put_device. Signed-off-by: Pan Bian --- net/nfc/netlink.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 376181c..e1f2057 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1107,7 +1107,6 @@ static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info) local = nfc_llcp_find_local(dev); if (!local) { - nfc_put_device(dev); rc = -ENODEV; goto exit; } @@ -1167,7 +1166,6 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info) local = nfc_llcp_find_local(dev); if (!local) { - nfc_put_device(dev); rc = -ENODEV; goto exit; } -- 2.7.4