Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp599844pxx; Wed, 28 Oct 2020 12:05:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl01QGhnfVjJWBGiAbs+zG/PnC0wbiSpG38Kb4LDPOSjOHvPzCZMaX2gIZgNm15h5Ac1CI X-Received: by 2002:a17:907:960b:: with SMTP id gb11mr534074ejc.396.1603911937234; Wed, 28 Oct 2020 12:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603911937; cv=none; d=google.com; s=arc-20160816; b=Ktxo/ltL/GYmX+lsQqPZvTEoKfPaPVkNCQatRznr/unOYxG5DpPtRalV/beuMnZ/JI Sbf7P1ugEic5TBRgZfe8tate7zboV3YTj51mBOFlmIOGCgfBp/yB8LuRSHxBhJBE7wO6 qA27aLtox0cUqvYmAoGVFylvOsck80ga06PQi3FkOCF1uewNNEuetijp8BP9LcP8iolf 1jpBkPpJJyeiSLmPDGSL5g62J5FXBTNVld0J7lut/R/gTOziREyJ0zUkSipkX+uclCYt suFOPMWsZFBkeuZ4WXVGWyzSrkjsjYa9rv/B4AtjX0e0LNKk/xEc1MzWwJrHEyvv2AWa xBYw== 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=LAV9meOVkLubjBjG3aq/dfKRvJ5KoX1thG+yj/KZbsc=; b=p5JuoqtZIEOJx77/lGi2bsY4dfFzHi0yACfYcLOMWykeyd8Ys8CRmcNZzhz27u3/Sp 7M7OAKURiVUuoZatYHu//4AV3Ck0n2RCXJEXT0QFsXWf8Oemmn32z1wgdv32m/WBGe06 4WSb7VyIKy800iKIMSlOFULkW8Dw/0K4LUtYjZrbox29mZ05puafh4H1WDVR/+xu4Xyy r95Mq27xDVlPX57KbPIk8lp1vYuYeWxKboExqTUp4YH4BZSQKclQjEAKZOpFIUZOZjNC maKu9kjwatR8KVOwqyCEHzF+v3ayVINtzSfBvYVtXwtacN+MfUwrIujerZ5dzV9G1wTI 9lUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S+iINyST; 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 w23si165eds.571.2020.10.28.12.05.13; Wed, 28 Oct 2020 12:05:37 -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=S+iINyST; 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 S1826202AbgJ0SRW (ORCPT + 99 others); Tue, 27 Oct 2020 14:17:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:60822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756141AbgJ0OLe (ORCPT ); Tue, 27 Oct 2020 10:11:34 -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 6340922281; Tue, 27 Oct 2020 14:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807894; bh=NhuI1P58c7ShbFFRt/V5OHPSBwBAN1XrTIJ+/ne/Zq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+iINySTU25qFrV03gpoc2mSAjpafHW4mi904wqXFyo+ynAx4yfpOhyjhNobUrgbo OuI7lFPWjTNGX4hP6i8YUTR4HisVCm+pc1wB9x09sdrhmvr4NVd/yeB4ruSk0g6Ouz Py9Z1advhkVRqfgB2cDDSnoXEEsp+gwWMV0c9vI4= 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 4.14 081/191] mwifiex: fix double free Date: Tue, 27 Oct 2020 14:48:56 +0100 Message-Id: <20201027134913.577890946@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@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 fd5183c10c4ed..0e858621eef32 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -1973,6 +1973,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