Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3032839pxb; Mon, 18 Oct 2021 07:00:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJa5HNqtYNtwdsA0Aax12pvAByjjCQcYACBrS+fwa30Ex8+9sKPwjoQP1fEO+MxpcGpXeL X-Received: by 2002:a17:902:ba85:b0:13e:c846:c92e with SMTP id k5-20020a170902ba8500b0013ec846c92emr27360729pls.57.1634565631704; Mon, 18 Oct 2021 07:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565631; cv=none; d=google.com; s=arc-20160816; b=WjACWmfwtoarmSBpf08EVFqVqzdZE0vJewAysUMr8hh1hZHN/48vBDHHjx0Ok9AC7l 9qQZq7viVQRVSWjiiy8jQlAl8tKEpmbqM+1b5246O6YfgQ8y4lH2RDwmQJSPnyVTiuo/ Iz1xn/QEEmkwFVXu2AhuPoZwdD883cN1PYj0EBe0CLmcw1mF4zil0ZtgBAbtVi8XwvKg 09ugBvDuhrSBoUm/99ewZe7G8qh0PAgYij0fY58CWfS0A5i8Uolg441zsMm/2Ke4J/eM VMK8NWBH5aB84qdzVWxaIqs4cGhu7EGPR+JCYTR0Bp3PYoZmsDybT6wQEG+xDrOJY68d 5Rbw== 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=daTTfk6M+bG1AVzl0rt56+4q4Jq36L3AXoUsQPGV0tIgvKED/EE2aFe68aCRJ5pzo0 glz4Za2pgK0Pf71Y3O4lQ7c1kAheKt9mcDRgVmHfLngcmtt5wRxnfZgpwlj3QPaDrOZr ZM9qGTzhI7bYf965vx5j0Jl2oz2X3q0WhYzshs7qttc9wSmC6E1wrPp1/pHTzDtic64P WzxumS+shr8kwiLaq3rkKnBp36pehnDWF+m7YMVhhdCMR+qdZSg+2py6YZca7kJRXIgb VxVsmmvTmPLs1DbzSZCy2oKpXVsI6F3L5E/G10zBqUS2uIgfff5RP3jBGXl8TNuXO9rh JVIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UkFimG4U; 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 pi12si21527682pjb.98.2021.10.18.07.00.18; Mon, 18 Oct 2021 07:00:31 -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=UkFimG4U; 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 S232644AbhJROBc (ORCPT + 99 others); Mon, 18 Oct 2021 10:01:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:39880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234467AbhJRN7Z (ORCPT ); Mon, 18 Oct 2021 09:59:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 981B8613A9; Mon, 18 Oct 2021 13:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564510; bh=5dlnK4dzyi2Jw1z3okBIXu8lZDl/jvlRZV3/+8AL1S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UkFimG4UmhrAuAlEKmvBS+PFnVjyxxYK4TqttjdO5Jev4Jx7kpCXajKYoKnPJdrL5 bu++ODugcC9wYGOnyuYn15THEhQajgu/zChyvpAZ1CxFkE2uIuim9M2ZAgETxn1aIl aOoCcQRIVy0KX549jb0O7gssU4TvaRYLqAthhMzU= 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.14 117/151] NFC: digital: fix possible memory leak in digital_in_send_sdd_req() Date: Mon, 18 Oct 2021 15:24:56 +0200 Message-Id: <20211018132344.476820148@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@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,