Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3422141pxf; Mon, 29 Mar 2021 01:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTo+Xv8c07pwDQpf3vfEd46MJ5Zh7sxylyvR377HAjSwq5bc98Ajw9y/JfCD3Nx0RFOMdR X-Received: by 2002:a17:906:5383:: with SMTP id g3mr9701582ejo.185.1617006979901; Mon, 29 Mar 2021 01:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006979; cv=none; d=google.com; s=arc-20160816; b=D+J5gQy5kQYD/4GH4teObBEOxSYa/DYR/nrrIKqbQVaZcBUMjuAzSpaOZklSZiV0kf zRipIXso7ClHhPF3lA1nK5mMsA4yLQCf6qG+8PDkRnkSZh1rRlVIKvYUaagioiDii/PF kLWHRzSkCUKpMFzG0+kS5v1QcKONOC5SUg21jnFoMEVoaj79mQv0bT4BVS6942VqGuil ssFKGXVgBIDBTUTyAc1SG2Zpn0qUql64MP/PY6kEvR7dEyfxWLCTZdvUSmFgNL4QpcRy 6oH/WC7wWjZndAqcB9VVUyQkhpKmyEpSSMXOhyaj0QssiK3Qe/5jhxJaOT4devI5pWBy wNmQ== 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=LI7KnShRaVjTuv1Zpba5sbzavgnEUeVqEZVp54j4Ic0=; b=COwmCigS7oA+nsSH9q3ttpvoYYtUA9NM/hikKTOphq5NpwQi75imhcNtl0zV02SEjJ nTebsRGIhVf+j2uUKg39eapdIoC00uzhbes4uUeL8pUuYor+D5joOqwKaCMu5UvvkHUq xDlswkExNUFRloSjIajorvcR3oPrFJl9desMy0mtu+zcLmgNljTmrnroUtuTMfL77vTE GudXWtmiSp+HAobjERvg8yBlees81WtDlqXMsfb7XhQc5ErnCDlDhxG6z/kWovK9IyXV gk5SEcltYBC8GSjaTd38rH0E1I7VzVzQZR6n9c7Sm86IhrsDYBzs/ELmwW7pelF6vbVZ AGWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lJ3uKEXd; 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 jz16si12427663ejb.586.2021.03.29.01.35.45; Mon, 29 Mar 2021 01:36:19 -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=lJ3uKEXd; 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 S234056AbhC2Ief (ORCPT + 99 others); Mon, 29 Mar 2021 04:34:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:38360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbhC2IVT (ORCPT ); Mon, 29 Mar 2021 04:21:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B099E61554; Mon, 29 Mar 2021 08:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006079; bh=Qa5G5wdax085QRuIxKwFZtL3LCLuobDr38WuPDQeiR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJ3uKEXdlEjek0FAz7wLLxUaEE05HSRjDwk6icjzHmXUv6t3q28W/MACg2AmKNdcf iRSnWgGyqxZNNR2Vpn22IEEUaRVWDztwJKf1gCKBErxiaRlKzNxhYpyDkEpwJZ3OL+ slUKiK3aXItIeS88QlLYO9+nw25HNlRD87/d6hec= 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 5.10 111/221] net/qlcnic: Fix a use after free in qlcnic_83xx_get_minidump_template Date: Mon, 29 Mar 2021 09:57:22 +0200 Message-Id: <20210329075632.916173766@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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 db74623a3850db99cb9692fda9e836a56b74198d ] In qlcnic_83xx_get_minidump_template, fw_dump->tmpl_hdr was freed by vfree(). But unfortunately, it is used when extended is true. Fixes: 7061b2bdd620e ("qlogic: Deletion of unnecessary checks before two function calls") Signed-off-by: Lv Yunlong Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c index 7760a3394e93..7ecb3dfe30bd 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c @@ -1425,6 +1425,7 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter) if (fw_dump->tmpl_hdr == NULL || current_version > prev_version) { vfree(fw_dump->tmpl_hdr); + fw_dump->tmpl_hdr = NULL; if (qlcnic_83xx_md_check_extended_dump_capability(adapter)) extended = !qlcnic_83xx_extend_md_capab(adapter); @@ -1443,6 +1444,8 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter) struct qlcnic_83xx_dump_template_hdr *hdr; hdr = fw_dump->tmpl_hdr; + if (!hdr) + return; hdr->drv_cap_mask = 0x1f; fw_dump->cap_mask = 0x1f; dev_info(&pdev->dev, -- 2.30.1