From patchwork Fri May 8 12:32:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90FC0C47247 for ; Fri, 8 May 2020 13:18:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6243824966 for ; Fri, 8 May 2020 13:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588943882; bh=rIvUnN0qPCeX6EYEn5S5OcwALRbUK6B/Lh0xuvzRDXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=owufysKLg3QOeOi/5GW7UUuwLK3sxF2vLXkIdUJXgqNDFQ/Uvj3XzRiMqX63NKtJH xHuuEFqvHI8my1nwbIwUMs82RJ8oWkXe0xnJDjeXcGYyQjzKbqgvsLBmpJEOBMwUg6 15WAS2x+m7QaC0GGxSr/aQfrHYPnRZlu/pvXf4/o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgEHNR5 (ORCPT ); Fri, 8 May 2020 09:17:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:41380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729081AbgEHMnd (ORCPT ); Fri, 8 May 2020 08:43:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4631224978; Fri, 8 May 2020 12:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588941812; bh=rIvUnN0qPCeX6EYEn5S5OcwALRbUK6B/Lh0xuvzRDXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rhzMWv7QRdBMuMilMOSZE25fttjVc+vzuuNep4gZLzCC+y5nH9O+k3/bJ2JkwBhl/ 4mDySXSs/bBJFRY75w3v6B4vCk5HwOmOPDdpaySVJIE0BZJsBumkU5M+6iiP8XHkgD o46bj6XiYwfEEgAPz4oUlCpBAWxeP17hzxcz9XVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" Subject: [PATCH 4.4 181/312] qlcnic: potential NULL dereference in qlcnic_83xx_get_minidump_template() Date: Fri, 8 May 2020 14:32:52 +0200 Message-Id: <20200508123137.216615221@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508123124.574959822@linuxfoundation.org> References: <20200508123124.574959822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter commit 5f46feab87bb105d6a217d966b327fdc56696802 upstream. If qlcnic_fw_cmd_get_minidump_temp() fails then "fw_dump->tmpl_hdr" is NULL or possibly freed. It can lead to an oops later. Fixes: d01a6d3c8ae1 ('qlcnic: Add support to enable capability to extend minidump for iSCSI') Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c @@ -1419,6 +1419,7 @@ void qlcnic_83xx_get_minidump_template(s struct qlcnic_fw_dump *fw_dump = &ahw->fw_dump; struct pci_dev *pdev = adapter->pdev; bool extended = false; + int ret; prev_version = adapter->fw_version; current_version = qlcnic_83xx_get_fw_version(adapter); @@ -1429,8 +1430,11 @@ void qlcnic_83xx_get_minidump_template(s if (qlcnic_83xx_md_check_extended_dump_capability(adapter)) extended = !qlcnic_83xx_extend_md_capab(adapter); - if (!qlcnic_fw_cmd_get_minidump_temp(adapter)) - dev_info(&pdev->dev, "Supports FW dump capability\n"); + ret = qlcnic_fw_cmd_get_minidump_temp(adapter); + if (ret) + return; + + dev_info(&pdev->dev, "Supports FW dump capability\n"); /* Once we have minidump template with extended iSCSI dump * capability, update the minidump capture mask to 0x1f as