From patchwork Tue Sep 8 15:24:44 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: 264132 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 3C251C2BC11 for ; Tue, 8 Sep 2020 19:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 017A7207DE for ; Tue, 8 Sep 2020 19:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599594829; bh=8rZ08HburNd4t19qWY2jSL42tAVbf1sq2C5q0vdp868=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=drWCUqDauWDiAGoeOp5PKgTOcwIhEwtMkbNhIqsZ0LdrYralo67i6ZZCQmKO5sbcB 95L08lLMpzbIw0uGNSKikxFkE3u498TPjKNTPTbTPXmblo/lLIgVIR840z3lz/KBho Am7U3tMbwxs+f0X7luRZcUb8JL12ZLgBJ5bOpVww= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730446AbgIHTxq (ORCPT ); Tue, 8 Sep 2020 15:53:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730511AbgIHPrH (ORCPT ); Tue, 8 Sep 2020 11:47:07 -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 899F024816; Tue, 8 Sep 2020 15:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599579830; bh=8rZ08HburNd4t19qWY2jSL42tAVbf1sq2C5q0vdp868=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P4lkCpLWqiQIa12r87PVKmTPmudrbU5SDqRi8jJRz/iOtHilr9pJKrVrgoyzKIIG3 6r9kLgGh1vBHkUesmrEzc8Gr/cPjaU3HnJ+94WpEy8skY0FEvI8YJDQtCI60CJj1He MPlCz3VYk5oK2OQuQFHyB6mV9W10PBEse/rGZFW8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vasundhara Volam , Michael Chan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 043/129] bnxt_en: Check for zero dir entries in NVRAM. Date: Tue, 8 Sep 2020 17:24:44 +0200 Message-Id: <20200908152231.831201640@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152229.689878733@linuxfoundation.org> References: <20200908152229.689878733@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: Vasundhara Volam [ Upstream commit dbbfa96ad920c50d58bcaefa57f5f33ceef9d00e ] If firmware goes into unstable state, HWRM_NVM_GET_DIR_INFO firmware command may return zero dir entries. Return error in such case to avoid zero length dma buffer request. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Vasundhara Volam Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index de9b34a255cf1..fd01bcc8e28d4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -2161,6 +2161,9 @@ static int bnxt_get_nvram_directory(struct net_device *dev, u32 len, u8 *data) if (rc != 0) return rc; + if (!dir_entries || !entry_length) + return -EIO; + /* Insert 2 bytes of directory info (count and size of entries) */ if (len < 2) return -EINVAL;