Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3016209pxb; Mon, 18 Oct 2021 06:40:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznQtYZb59Aiy4NOfbYzh/fZapCLsJgFDPvw0ZXwbMiSGh3PHn66ZgPiuJNaHtZJ7AsAGCs X-Received: by 2002:a17:902:c401:b0:13e:f5f2:f852 with SMTP id k1-20020a170902c40100b0013ef5f2f852mr27492378plk.29.1634564400768; Mon, 18 Oct 2021 06:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564400; cv=none; d=google.com; s=arc-20160816; b=VSXd+rrbqjbyMqqKpDFYUM5nxihp9EeEyajI5UwI7K1rbj5aVMEcQqcV3XLuK+ViUx BvYAyZ+D/t1oNgCj+tLdAk+7/xEAkWxYtnIcc8j4BIeRsvsmDCFzdlg+mzmN3LWY7YM8 iJg0jEihYj1qN9rP9uFbHHXknJ7IYyVc+qI2SZq1D0F6uSR+hXhMR7WlIoYzDRjy5LKn Bmw6chtZx3ERw+EREJhOHWxDcckQPe7nkHU1c2VKMrWupCIyEu0ZYLma3jF6VRXxQjrT CxZ6Afrev8ICrK8Rkt/y0HK1UCKRHtWHhC9sYUH84j39C3BnzAaQH0HBsCV4UQ8x76z4 wkiw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cZnrghRj7kVb9aNm0dNM8JMt2jUms9YpndrBOQAGG7A=; b=wv1XpwUqz144SpIt4BJ5Odsg28U09FTgj/+422g+szQmVUV1gHGyHYcTGF65xXNOxP C7In5Dp8hzLgkuYDZVcAK7orIZpIvbogrcZqLH+jG9HUqMEIuzFPjbVymrk4xnKfUy4R 3gBl2nrsNq+r1ir/UjMFmeop/iLI1Z4cpzUz1eKnsU0SzUPgO1SjWinhb+OcGesSocHi o61TefW42PPPqqWVRsvoYOuQ4SuQXrdfhmjEkD0J2nKsb4aOEteF42vTpuSXFcLmMOfT 68dHGzIATk6V+eJPiv5jnW9I71kJXsLmdgn+lSxkGkVGy9HhXmizXxCnlE9LmBEhq8Bt ue+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1FKPYz8v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si22366697pli.413.2021.10.18.06.39.48; Mon, 18 Oct 2021 06:40:00 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1FKPYz8v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbhJRNky (ORCPT + 99 others); Mon, 18 Oct 2021 09:40:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233716AbhJRNij (ORCPT ); Mon, 18 Oct 2021 09:38:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C04561373; Mon, 18 Oct 2021 13:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563937; bh=5dlnK4dzyi2Jw1z3okBIXu8lZDl/jvlRZV3/+8AL1S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1FKPYz8v618zD6fs4Qjt3W/5dglgfTYezS0gqVPJ7PtcYXtK4vIforaWsSHGlfnCB B2VyiV5VcqXU96TdaOagQgrK365BX+xyr3vNFy6KRxxdoSkYWppTmah3E/5XSKhPlZ RT6qsxmoHBh8Y8BnklGVJWttu3PafzJs+s0cMfkk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ziyang Xuan , Krzysztof Kozlowski , Jakub Kicinski Subject: [PATCH 5.4 55/69] NFC: digital: fix possible memory leak in digital_in_send_sdd_req() Date: Mon, 18 Oct 2021 15:24:53 +0200 Message-Id: <20211018132331.302290292@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ziyang Xuan commit 291c932fc3692e4d211a445ba8aa35663831bac7 upstream. '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 Reviewed-by: Krzysztof Kozlowski Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/nfc/digital_technology.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/net/nfc/digital_technology.c +++ b/net/nfc/digital_technology.c @@ -465,8 +465,12 @@ static int digital_in_send_sdd_req(struc 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,