Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp417918pxj; Thu, 20 May 2021 12:20:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydLAY4yPS6qWHR2fYzQ9/dI8lSSvUUW4K7fQt6gkuoj4xzmnKK8VZwLfRAHt9MqmTwmOWs X-Received: by 2002:a17:906:f6cd:: with SMTP id jo13mr4296975ejb.493.1621538459121; Thu, 20 May 2021 12:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538459; cv=none; d=google.com; s=arc-20160816; b=VNtz3iq6mTU+y6/W8puCuvJ0atgwEwq70xigblymYxpBRh1N7tsJUaCT1DzWwtX2z8 5D4C3a1cEBTnAVOdPwML3f7ClNas0jpk/Y/hf2GkQyIMJnuMBAwgbBUQAfbXMAPmjEie qBccDsoTQWj+9Su5kWMYVaCqt5ZI4b9sD9Buyi+pFPE+u4nBZeU2P9UqjDfaEacqpdIw bS4EwvSmwP9fBMCkcc7N1h+UFhbl/R41alO+0KKVEf9SqX3d4ZzbpC0v/Unj3Q2i9/2r 86id38sRgYxpVv5TA5ODsjQLVCiJ3CwIuNiTl/c9ept2RooBWVJsl8C4cyhgCGmXnn3N w0Kw== 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=OyPblVLOqYTYfxa99fEc34biDQSE/gOFG582YhJckaM=; b=VqwtMbAy9kcIf6WXHI/ftQUj/cFQ3rR+uDbJOXXWf+WTWDCL4MaFXzJBiSQzPHwwmI S8abZqeA3XOs0A1kP4PBvsqRLARAlS2cMkxbgMa7Yaq75fOyqqXq6umq/auDW6vuEdwu CDg7iqZh8GNEBlFb8BZZg9L5yTucocE5hLzUZHhXaqbue6gT8ZvZumEjWwS6McPZsA6X ngNr4oryMEE+dSdOuPcuGhMxBZvWc5Fm/dOyr3IJeWqoepiCc+7QrVZm8ttXvXDA9Ykq NfNiFFsIIdOWrcFr8PTTiBWYLwWqTcqDVgfr4fzyIj1gCE47fQkm7GRov3Zdw2N+S0cx 6ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q44Bwe3e; 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 v20si3110679ejq.133.2021.05.20.12.20.35; Thu, 20 May 2021 12:20:59 -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=q44Bwe3e; 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 S238775AbhETKuR (ORCPT + 99 others); Thu, 20 May 2021 06:50:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237406AbhETKeR (ORCPT ); Thu, 20 May 2021 06:34:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A66F161C56; Thu, 20 May 2021 09:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504396; bh=QLJjFypi65JDbScRZIz9INsFoQm67Ejt9XfgE9HuiH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q44Bwe3ehbqgpd2cLzctZSpajFILbh1ywA2mom7am9o6YQJKQ9NMR0wSJHIj1GpLF pFzifgsv80wNG1T51868hs76EuP/tU5r4NVOMqZ9+zL7n5f3cF4xOdR1DiTERfh/T/ 3VDfP38VfSGfM0S6eeQH0aa9Csfhz6YVTrl+xWEA= 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.14 226/323] net:nfc:digital: Fix a double free in digital_tg_recv_dep_req Date: Thu, 20 May 2021 11:21:58 +0200 Message-Id: <20210520092127.891539071@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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 4f9a973988b2..1eed0cf59190 100644 --- a/net/nfc/digital_dep.c +++ b/net/nfc/digital_dep.c @@ -1285,6 +1285,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