Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3011573pxb; Mon, 18 Oct 2021 06:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSwtIazoUZKTa29Sntg8C+KZfhFO5zueQuuEm3nymfr9hkc2Vy4nsgF9Z65zkgaFBE2lVz X-Received: by 2002:a05:6a00:22d4:b0:44d:1c39:a8d3 with SMTP id f20-20020a056a0022d400b0044d1c39a8d3mr29171288pfj.56.1634564069416; Mon, 18 Oct 2021 06:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564069; cv=none; d=google.com; s=arc-20160816; b=Py/FsM4XCtyUOU1hWYpfv+jbZNWMfibNmvswFVm3LVzpy8WYGyzuBzskTwqGFzTSbJ 4Itjsh0OIhsXDCCfuQi6BesIPN8BEeAlytX4jn3nuTtlIL+IMsiNzdRI8fh3nXZJHuDj BPJY/W9YaDBtdoKyjp8mMrscHRLQZejmsFRRFu3FnG5FnJT+B9vBNawDwtgiltiiGX8N AEfgp2sPvF8wCVxUFWGh3ERo2kAmhYpgeRf38mlms6TLGzBpbYJx1H8+4Kif1g5bnnmR RRdT9k7+ePKDCuCCL5EOzkAjJtpL35CeAZB0xhQeT13bpprxzjX+uZe2VsmPLqgQXSLp n5+A== 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=Ryfe3eZ4I81rgYegtgPKuBIpRBKMdCC8ozk3lM/aaL0=; b=jILrvfIBorsF3SKkYSuSLHfHWG4DYvmhR8gzTjwLiL/FpbEca3hdPthVPCaNlENwbq k6BAPxohUiy01r113hPVeNq4U1b5eNuaP+l1JpQ9papwLhWx/LL9kvTbgoUXd8MQvtHs wSBnxpgd1VYpo5d4rNZS7y1evvwWizT/G5yXoE7sOOBGV+f+vL5/E2nJTvKExicl3dAk XE682fOes0KF6ed7Au2f/QieVk9V9BK0bZ7zH4Xz1PUGksdwEhr2Jd5l25AU/2FLICFf DR769QL3pGXeEamKCQ8j49W772Yfow8R3bpnR0n/7h95aYDHpMOvVzDM4igelMb6NWs7 pfBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kgZpSCCi; 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 w2si4379886plq.368.2021.10.18.06.34.14; Mon, 18 Oct 2021 06:34:29 -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=kgZpSCCi; 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 S232521AbhJRNfR (ORCPT + 99 others); Mon, 18 Oct 2021 09:35:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:42364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232414AbhJRNbP (ORCPT ); Mon, 18 Oct 2021 09:31:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F0FA61260; Mon, 18 Oct 2021 13:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563724; bh=MS2Uw1MMjZwdjNW3SLFOaCILxBT4iMo0z9Hy+GL7sD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kgZpSCCi4egF5KdPnobq88zL4eHiy+18UXSCopZjY2MnqKCJP03vhYkPsahEN16DX qsni2AE8XUFVpOGx+n7bWyfdiSjgYcUwpaVF2RjuHCVoGFd7gHZD/MG091JAYSaH6i qk81yU2VmByPQLEBstlzgrr8zvebTmuBuerATR4I= 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 4.19 40/50] NFC: digital: fix possible memory leak in digital_in_send_sdd_req() Date: Mon, 18 Oct 2021 15:24:47 +0200 Message-Id: <20211018132327.847132122@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132326.529486647@linuxfoundation.org> References: <20211018132326.529486647@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 @@ -474,8 +474,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,