Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp626752pxb; Mon, 25 Oct 2021 15:17:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQBUvTn/OY0Wv1d1DGC0gYkd5bogMPTBO2F1C3qgrSzrld4O0dPvjowG0lL0nQotlnIQSA X-Received: by 2002:a63:724f:: with SMTP id c15mr6502164pgn.227.1635200244203; Mon, 25 Oct 2021 15:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635200244; cv=none; d=google.com; s=arc-20160816; b=nYusPGfqRHXzqih7Jreh/BBlG9zkHw55tq51rGXWtGtV788NAQqHf1GdvU/NqoucTo OX/DvLDmcZYmZWhv5Uf/Z3efi+qkm5geXdU/WTwHw80MEjBoXvY5DQCPqley9Tq4Ersr TQMMZqcwculTfybavI9i03IZEzwA9WxanU7hJLntdh+7MZ822pJCkVIZNPzB3F/RvWpp pZz4oKWzHwvpLdQiWa92DZ+nF/VA2wG41wOXzE0Ip2MHG41SxtrXN2MrffFoYrHNd5Gf xyT2UHC/s4sBIxExE+f8dxKLtxPmBrIkotZUdAlSezOao4g3QApJgpUZKIet8CXWHM9R Qe/Q== 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=wUx2oY9a67HM8wesRHGgK+9kOup/dUvgcj+gbWP6Uqo=; b=KCqQ5SckQbwDV10DXZeKGRLKOTzRYC10fgfYRp4v6nMFwLi74YWOpHDgFJFJa9VUea zV9hWBv2SFCQW49sNM7aK+VyH1/SSiTYWDMsHgvdwburzEgAAaKELHI02AYw3AUZj7IH wCLvDxQztymNvlQHOCHoMmMY3jR/1Rjm6dq2/qIdw8aUI1I5BcbF2GeyQ3rf8jj6jPgI 6vV3ZzBfJKkPd50PsX7cc0d99VIAUvGU+IgiKGaycbtsAMLeTKUTuRpvw/a8jGsgeNQJ pQXBVyyNEKItjqUaBksMWDfNUlYKXpjSN5yIt7ou4bqBx7NGs1g8bIxte7FsZQugfUJ0 iFbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vH0I+ooP; 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 t5si2187371pfh.90.2021.10.25.15.17.11; Mon, 25 Oct 2021 15:17:24 -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=vH0I+ooP; 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 S233930AbhJYTSO (ORCPT + 99 others); Mon, 25 Oct 2021 15:18:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:35288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233987AbhJYTRk (ORCPT ); Mon, 25 Oct 2021 15:17:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F232B600D3; Mon, 25 Oct 2021 19:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635189317; bh=eEyOtvoc3xqN8DzFW9FIa9KJoMprXbBPbIFhL9Vi7rY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vH0I+ooPP4b0YEgfmXNayQ1Ntk0zcAIbmK35oORxxE+MX/iG3VZK9mgZ8/GuZkfIS mIUbD/50fjnXzP8xJRplq/4UZP3NwgXLqZeAIKOZ+lWM8hydQmedIWrHchsb2QtOXY FBSuvbiYTuyj6YOCFvIlK/oU8ChHcJAH6eXHKGjs= 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.4 19/44] NFC: digital: fix possible memory leak in digital_in_send_sdd_req() Date: Mon, 25 Oct 2021 21:14:00 +0200 Message-Id: <20211025190932.648253354@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211025190928.054676643@linuxfoundation.org> References: <20211025190928.054676643@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 @@ -473,8 +473,12 @@ static int digital_in_send_sdd_req(struc *skb_put(skb, sizeof(u8)) = sel_cmd; *skb_put(skb, sizeof(u8)) = 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,