Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3207383pxb; Wed, 13 Oct 2021 00:55:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT3OqHa/G8QyPj1w/z/3woZyEBIzGMAS11bKpcMuTOXXX1WL7r/ABXwjl8YRbpnDVhpLla X-Received: by 2002:a17:906:53c8:: with SMTP id p8mr38031840ejo.422.1634111740842; Wed, 13 Oct 2021 00:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634111740; cv=none; d=google.com; s=arc-20160816; b=k/pGB1HAEx+9jcOfblKzNEeLcxcKZxwFJM5jKGxpfqEQWUPRYJcB0mBPCT5Ku+1fEb KmZkZL0KEeYupjXXrMoJMS2OGLL2zRx5ATFczzYjTdOd7ze3n6rYPwAL9U7awEU9yyjY HNhuqp833FU0N1SN3T8o/dJMpUkQQCVXpjYd/+YSYiVNyAzkv0kfBmWvAisOaxYPAS8C jyyzOxk05egR9jBah15jKCtCzsIB+l71Z/iwnz9rK8qj9KDlu6rMEVIjPFsEKXSD9B4Q CbDTwKkigdjs4pV5u8hdpJi9Lo1PxB6q6MmgEu07YfBNiA7chVcFqg1WMFe4/FVxW5Fl 6zRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PVOh1XGxgThzqqJMt5K9TPBJm96aK4g0uIuO3ALjHYg=; b=vIO4D0SOYAuoGzylXFBHhy6mLgEf4Jbubspb/EKX4M9Zn5+45229hhsBCryzitaA3E 0eUMaCFHeEle9GuDcGjMtwwS4k3TiMWeFsBpNhcMNbFby0IaU7BNO613iak/ru42/G7U m5ZK0m+GuWSJ/iSbNnugKyAVDguZhySvAnYqY/yiqON+b92/UgXlOFAbu33vpvCsid9O QsW+fmJ/YRlR0cMBFnxB7+8adkL8U6R5IC4MCn37Rjpai1D/FhRThOkcYDe42AMBQBOr PVrxFTOnPZjP0umUgXVBqGlIzuhLAoSjY0PTVDmn6pweyArY2rLyVNmQZZV61AJy4RKY bakA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp2si31684685ejc.176.2021.10.13.00.55.17; Wed, 13 Oct 2021 00:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238708AbhJMHxf (ORCPT + 99 others); Wed, 13 Oct 2021 03:53:35 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13733 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238736AbhJMHxb (ORCPT ); Wed, 13 Oct 2021 03:53:31 -0400 Received: from dggeml757-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HTl715TnjzWktr; Wed, 13 Oct 2021 15:49:49 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by dggeml757-chm.china.huawei.com (10.1.199.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.8; Wed, 13 Oct 2021 15:51:26 +0800 From: Ziyang Xuan To: CC: , , , Subject: [PATCH net 2/2] NFC: digital: fix possible memory leak in digital_in_send_sdd_req() Date: Wed, 13 Oct 2021 15:50:32 +0800 Message-ID: <56fbe3414c94916d197a1a1b3e438eaa129d5c9f.1634111083.git.william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeml757-chm.china.huawei.com (10.1.199.137) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'skb' is allocated in digital_in_send_sdd_req(), but not free when digital_in_send_cmd() failed, which will cause memory leak. Fix it by freeing 'skb' if digital_in_send_cmd() return failed. Fixes: 2c66daecc409 ("NFC Digital: Add NFC-A technology support") Signed-off-by: Ziyang Xuan --- net/nfc/digital_technology.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/nfc/digital_technology.c b/net/nfc/digital_technology.c index 84d2345c75a3..3adf4589852a 100644 --- a/net/nfc/digital_technology.c +++ b/net/nfc/digital_technology.c @@ -465,8 +465,12 @@ static int digital_in_send_sdd_req(struct nfc_digital_dev *ddev, skb_put_u8(skb, sel_cmd); skb_put_u8(skb, DIGITAL_SDD_REQ_SEL_PAR); - return digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res, - target); + rc = digital_in_send_cmd(ddev, skb, 30, digital_in_recv_sdd_res, + target); + if (rc) + kfree_skb(skb); + + return rc; } static void digital_in_recv_sens_res(struct nfc_digital_dev *ddev, void *arg, -- 2.25.1