Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp623062pxj; Thu, 20 May 2021 18:12:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJj+3DVEanxxojQu25HzJP7lzpezMd0UXnySThe6Q38EhzRl9XgzJLwIQPHyT+dnstZ/7w X-Received: by 2002:a05:6402:203c:: with SMTP id ay28mr7845080edb.100.1621559544167; Thu, 20 May 2021 18:12:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559544; cv=none; d=google.com; s=arc-20160816; b=P2AodE18xkPbflaWi7YRflz611ZG0Le+6CShCNjIDyCNvwGZlvsd9SkTgf/7ChHTLs zUMnB2065C+JpAfGy/z8tJycZl6tFE7oGvI6fTDmz2mcQZ92E/MktPMNEzLhlcc/Rk33 Hk9xIGIKZhxLgRoFaxoUzTaNX9qEBcAFQ4ox1r+gCG3HqUWHbbCWVk8kCYOoRb/KtUjQ bDf2GMGo94WxdwTuEkMwRIwKlXraf9Wj8Y8eLhhRe1ewJ4OFRqlWmoSf2cYwshzmoQnq IdfP9wuVl1SoeaK27FN+jP4d+8ypZz3YrQqQG6LtGNPd5bufMzDRzmTAkzk3GVEb4tcl xmDA== 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=YGckC9NgG2NGpvIoNh/s2cj4Qe7K5j6FCTFPrdhyN/E=; b=vtWWWKUkkACnuCWWLQwGxr4iB1V3UKle4EK9xwJo+oFbF+u/kENJsCClfKBKk1g8zz AOzMadBcCU3wowxWMPgrPCEd8NlsEP1zUi8OBLa4TWDjSb9u6DXo/o0vs1evHpsmWCqJ vf3QRYq/gjwPwvsmvWa/uLdIL9DBqQSn+kJsyTifZEmjHA2kXloHx0v3w4kKmXzh1H5X 71ogSII0WesfG6T5QgHfSN/VIr7MS3joEmp0FebskTdtdDDD2oJzU8GMDIrstacqEgw6 10Fi95XGGR3UwNcctA9zlQSEYTkhHNUvbvayiltQjKZy9FO+dYJAHwxy00aqU1tQENKH vmng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rBDLPaIx; 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 bh4si4763539ejb.358.2021.05.20.18.12.00; Thu, 20 May 2021 18:12: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=rBDLPaIx; 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 S242623AbhETLkQ (ORCPT + 99 others); Thu, 20 May 2021 07:40:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:38292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240760AbhETLTT (ORCPT ); Thu, 20 May 2021 07:19:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 33CFE61D7D; Thu, 20 May 2021 10:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505430; bh=BjKnVJBykX811GgN13nXf38dQHl2MuwBNEXcXZQj4co=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rBDLPaIx/eN5Ah6oEiEM+4ofAyE6OBR5976dwayxpq4fVZge5oGN1hH4G0UPace/a M1qo0pNoImna0KvTrw0ySYTri56vIUXJPzmTFGEynP+Ax8BEgpv3nWPErs0nsvuC2H UBHmo9CaCTOIdvrCtEgYmDG3JVC8Bs1O4ufzWtV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 131/190] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req Date: Thu, 20 May 2021 11:23:15 +0200 Message-Id: <20210520092106.527621312@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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: Lv Yunlong [ Upstream commit 75258586793efc521e5dd52a5bf6c7a4cf7002be ] In digital_tg_recv_dep_req, it calls nfc_tm_data_received(..,resp). If nfc_tm_data_received() failed, the callee will free the resp via kfree_skb() and return error. But in the exit branch, the resp will be freed again. My patch sets resp to NULL if nfc_tm_data_received() failed, to avoid the double free. Fixes: 1c7a4c24fbfd9 ("NFC Digital: Add target NFC-DEP support") Signed-off-by: Lv Yunlong Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/nfc/digital_dep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c index f72be7433df3..46375ff214c0 100644 --- a/net/nfc/digital_dep.c +++ b/net/nfc/digital_dep.c @@ -1187,6 +1187,8 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg, } rc = nfc_tm_data_received(ddev->nfc_dev, resp); + if (rc) + resp = NULL; exit: kfree_skb(ddev->chaining_skb); -- 2.30.2