Explorar o código

bnxt_en: Check for zero length value in bnxt_get_nvram_item().

Return -EINVAL if the length is zero and not proceed to do essentially
nothing.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Michael Chan %!s(int64=7) %!d(string=hai) anos
pai
achega
e0ad8fc598
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

+ 3 - 0
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

@@ -1773,6 +1773,9 @@ static int bnxt_get_nvram_item(struct net_device *dev, u32 index, u32 offset,
 	dma_addr_t dma_handle;
 	struct hwrm_nvm_read_input req = {0};
 
+	if (!length)
+		return -EINVAL;
+
 	buf = dma_alloc_coherent(&bp->pdev->dev, length, &dma_handle,
 				 GFP_KERNEL);
 	if (!buf) {