Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp162132pxx; Wed, 28 Oct 2020 01:11:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2N/KDOmnVoydqXJPzvaU3apqo1Bl3//maurdVZxYdGWEyQ4ZbAsjJnLvehz7xwfYCqW7b X-Received: by 2002:a17:906:e88:: with SMTP id p8mr6329528ejf.466.1603872675697; Wed, 28 Oct 2020 01:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872675; cv=none; d=google.com; s=arc-20160816; b=stTxud9MFdmUB5hiwLN70gYVrgsjyfDunzmAosdQ6DIc0xGwGy7vcc6bGszYpj5aLn VuxAZoBAagj9luja8m9E5lTsiXiIRafTmY7WnQ+86gHqEjimB4tXDUCRW0VMp0MZy/e3 24oiD5T8aWufWRWPUQANLL5XceEDOwPgs1Y7w5q+f2NCte2dug/UUgIH43DQLt96vT6m H9ajiVmikRc4kk+JwEJ5r0omKOUTHIVAM7qbQInmf50gvGjZbvzDIucps2C4Iz/52DHK agw0FN6vKYsv/l8ogChaiOSh3BckSGfMDXQlZ+5kX1rPUItGvDOwWVy6ptQzbV0JD2q4 496A== 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=rsJZV8NOGirIBCMkZrxkh4QX8Q1ZcnuonR8UPc4cvJU=; b=fsyqg75myuHYB7RoFyTN/H9hh7dO+yJfHAIiN1OFbJJfyjv+pBxRAYeLuDqFKS9PRb ibl/oaNXW1vW1j7QLhgVGzFnVAUs4UoGxwlQt3mdp4FEFl+AOe81EheBYqqXWj/+vN31 8hj4ja92KhVCr3DheDLfCfqdR9QUt1Kw0DIsIYawJ4xBedJAa1K+g4ChLIIFwrHdiLnE NmcnCvtUnEOVdr/YcIIcOBWP26Lh56q7ZksRW0VOkSv4njXsxrfpPLHMNCMrt+pWHcSW KFe9CL3xVlG6ZnOH11sGLjjercz9Yg5wQY2KMZp0my0T7WIkiOk3Gpaa5mEDz8KP/tur 93NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i4LiQyKy; 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 jr1si3058858ejb.164.2020.10.28.01.10.53; Wed, 28 Oct 2020 01:11:15 -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=i4LiQyKy; 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 S1753192AbgJ0N6u (ORCPT + 99 others); Tue, 27 Oct 2020 09:58:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:46110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbgJ0N6p (ORCPT ); Tue, 27 Oct 2020 09:58:45 -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 1164E2068D; Tue, 27 Oct 2020 13:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807124; bh=KosNPV72kowdq3WJsyQKyMqfTD132vjbfFitmoWx/4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4LiQyKyhXm0sx7CLmJqD9ZoEBSFm+eMSrUjJb9L813nqOZaXYw3UztSfxz4ZgLQh F+/Yg9AS01Go0ULRqZ7+NCDv6NVSxaDVIecfOWWAtqcL/WPYW8a0VXfIlcFaQ+qfQz J+TrnRD5reXJIHHzfU4y+mOzHi93+FxRTANeezBE= 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.4 051/112] mwifiex: fix double free Date: Tue, 27 Oct 2020 14:49:21 +0100 Message-Id: <20201027134902.981414532@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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/mwifiex/sdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 78a8474e1a3dc..abfe4e8700ed3 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -1928,6 +1928,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