Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp430166pxk; Fri, 11 Sep 2020 10:38:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5LRdGawXTFBsnEU7BD5mOJ1Y3yaqaFT3oV9SOxeairPzShAIZm1SkwG13Z5VW7Mx42kgb X-Received: by 2002:a50:f418:: with SMTP id r24mr3360813edm.295.1599845933584; Fri, 11 Sep 2020 10:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845933; cv=none; d=google.com; s=arc-20160816; b=tkDtnuKzGZKxkl+OKl8nM3wPrIEP7mVXXj7d89hFgi6ASeTxbjytTH8y6MpNf74Cs2 RhmLSpMKdURMQH1lpdSGGztlaD8swWRqS/zPBTRAexjL8TMO97Wy34O5EXn/I1vzDFGx j6FXsvwfqcxIDUIrmWe2N84jbqhfl1xFCjznIVgefYPl9QBpnLNkgV4zDtEoaGr4nXNs Qb0ZEuoCvaHznV/qVu7zLCQqGf0euslFme69kjVkC1CzcsBdY1R1lp96+MgSbHPr0T0C uAhzY1S7+VkaYMk4fbmx0lgqDfWDeAvBs5GW7JtBrEmONo5QOQiRQG0Xeg1REmAFfqwE zKmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=avuC1I/vsbt0ytSMEMbsGP4N6pOGT9ZrPToJOkRqWyQ=; b=a28sEq4v7kRyNqSI5TxLEm1ceJU78nx65+aPlbB8v7fQ6Svdb+3YBM2EX0sR12UiiS 5DsXZFPGXltuo0yd0zqdDDxYIaddWe3KTsXkEO5eBXVhSDRsuFuuaLKHy13L/AxkXIp8 QSIBBOuA5ecSWY7CfMs0WOW/rSrOruf2dYMsxL5/vNuezw5K4N9AAFt5pKABy230w6Ym yXldy2pJqJvHJdUI93vuDIKsc41hOmtF5/WD89KErS2Ow186+HdUk+3D2CcECIgDuPWD xPh1ElLbCdTHsKZsrE5gg587FZbb54eqfLbUYci3QM9XBxko2hwObK0Izu6VOXB9ky3m 3rgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Arkx8DQD; 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 r21si1648984ejo.309.2020.09.11.10.38.30; Fri, 11 Sep 2020 10:38:53 -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=Arkx8DQD; 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 S1726199AbgIKRfw (ORCPT + 99 others); Fri, 11 Sep 2020 13:35:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgIKMye (ORCPT ); Fri, 11 Sep 2020 08:54: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 960B022209; Fri, 11 Sep 2020 12:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828811; bh=vEi4E0w4uSHquCmKGvA81A6p95Ge5UOUtUwzKnVs9DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Arkx8DQDx+ehSLlXH/1EiS6/w6XGkLalZN0kzenet/Jn0RBKe1MsTN8lDPKzgeSGV K01XtnFXqxRPxfuZ5MA1QXHPXYpwvA/0YMU/4oIYkcuII9ZBIdlwABdLva7n/8p8yb UsTxZ8Gjl/0fy7NUXp6Xxf/SwTEib4s/yVXQcfxU= 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 4.4 16/62] bnxt_en: Check for zero dir entries in NVRAM. Date: Fri, 11 Sep 2020 14:45:59 +0200 Message-Id: <20200911122503.197604642@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122502.395450276@linuxfoundation.org> References: <20200911122502.395450276@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 45bd628eaf3aa..416fb16686a61 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -991,6 +991,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; -- 2.25.1