Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp224668pxx; Wed, 28 Oct 2020 03:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH6mdXqYxEn1039AOXsaCg6/+hxCVY+cJR6hF+qrltrovQ1TkAdXHbAaS6KbkHK4bCBMGI X-Received: by 2002:a17:906:4351:: with SMTP id z17mr6718588ejm.110.1603880444341; Wed, 28 Oct 2020 03:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603880444; cv=none; d=google.com; s=arc-20160816; b=unoev8B8VCX4Zwk7diw22MHM4XcxBbKaClnU31Fc/DGWQ97XOIOTWxOgi2y4ZMX8d2 EIsP8yTRH4mxo8z5V9jrG98XFQKoWuEY+BD5fHQpj/rFIzVzEG5JhX38TKeL5PY0uEnV nXujTRR20rWYd9VopqvTIgC+EdSZq29hQWHm3Z1+zx/O939QyE2TNkYqG8DEiOvGiPnj IlqmgUuFUNoeF6OcWtJPtM4Dwe7NY0eVR4UESqfoBeovYq5mRvZ3JqgNyIB+W/4Kl+Ao KzqMWeUywyc7+p6GbpaduicZ0fkhJGxiyQCWZlnai1zUQLKMTi3V/WvaLel1ISY2UrLe jxZA== 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=6IcCEiaECW9OgIQ8TqvmbwRJ/yUAPRiYkAEY7mCsa9I=; b=G/KxxlafE/byBOVzhphX62O4X1T3IMQyRkisTUrStTF0O1wgVIt8orgtipwYyxdYBY kxLU+c/8Qi9roe2+Vpf9HSfY9NIua3qQC5Ht8T8Ur8J62lxw/GG6r7W4R4uAuOfOt0Ky JF2DdlEdmz/D3QPdUI/Z4ODqpOoqJezbX3q4cGz8Z3KB+LblE16r8XGUD4hwImcCC2Z7 kk+XPcQqRZFvmltTksAB+HezxBJcgJDOBrqWR9joDdxZGx+wUS68K+ZV0FtC4N6TG7Mu sqeVN5JNwVChRtUoFBptO1OupJJB24vbMfJBZS+FcfGCDwTaOxdVxvRyT/mTkppgEPg8 MFOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zsUnfZjz; 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=fail (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 y9si2654785ede.591.2020.10.28.03.20.22; Wed, 28 Oct 2020 03:20:44 -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=@kernel.org header.s=default header.b=zsUnfZjz; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761196AbgJ0OiV (ORCPT + 99 others); Tue, 27 Oct 2020 10:38:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:37510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761186AbgJ0OiT (ORCPT ); Tue, 27 Oct 2020 10:38:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 50BB5207BB; Tue, 27 Oct 2020 14:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809498; bh=pQkBGN88BNHo2CFcrn91lyWD0LfQMd16lySgBfNaqXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zsUnfZjzwkmd/0rdxz45gjKpZkNiYcYzXQBtPWib1aoJRtgUgbGpBKcKu1Yn3LorC YBeLOGEhrFLVl0N+3TrhagxEnRnYYhp2mOCMeF4p4ItLLuQgoMMjHJY2A6cMPTLLh7 QZ4Z/3k4tOdjLSGakChqAXLmQstZnGEkpblCDqBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Brian Norris , Kalle Valo , Sasha Levin Subject: [PATCH 5.4 187/408] mwifiex: fix double free Date: Tue, 27 Oct 2020 14:52:05 +0100 Message-Id: <20201027135503.762898937@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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: Tom Rix [ Upstream commit 53708f4fd9cfe389beab5c8daa763bcd0e0b4aef ] clang static analysis reports this problem: sdio.c:2403:3: warning: Attempt to free released memory kfree(card->mpa_rx.buf); ^~~~~~~~~~~~~~~~~~~~~~~ When mwifiex_init_sdio() fails in its first call to mwifiex_alloc_sdio_mpa_buffer, it falls back to calling it again. If the second alloc of mpa_tx.buf fails, the error handler will try to free the old, previously freed mpa_rx.buf. Reviewing the code, it looks like a second double free would happen with mwifiex_cleanup_sdio(). So set both pointers to NULL when they are freed. Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver") Signed-off-by: Tom Rix Reviewed-by: Brian Norris Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20201004131931.29782-1-trix@redhat.com Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/mwifiex/sdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index fec38b6e86ffd..b322c2755e9a4 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -1996,6 +1996,8 @@ static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter, kfree(card->mpa_rx.buf); card->mpa_tx.buf_size = 0; card->mpa_rx.buf_size = 0; + card->mpa_tx.buf = NULL; + card->mpa_rx.buf = NULL; } return ret; -- 2.25.1