Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3525544pxj; Mon, 24 May 2021 08:39:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo1R4GRPqs6dKZxlDxWKv/6Ha3NuikRDRmjWbkoEp04jdtfNyUnMMZiH9rdTV7RK2n4kpm X-Received: by 2002:a02:7348:: with SMTP id a8mr25266982jae.116.1621870758654; Mon, 24 May 2021 08:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870758; cv=none; d=google.com; s=arc-20160816; b=KJ7NXWhFarqLADLb/5GyaVHf8LNtotoJePBRVSa7c/o9D/GbsaAGXvrNxAHGyXWmaP XFVRAIelUWYZXJt+iORFkJ8nljsL1ALPKU2M+c+Ku0ajzNBrI9vgflcwndgVvZhElQ2c f5+Dbhv0D1BjoGs0BOnMJBuKvd1HKr/K77Rp2zwhXtGUTFMdMr+Gw2Q5T706DtzGcmGe GZ7z4BDSP9OcpylpkuWm0PjGAqO64f6kn5h1d3AtmeW8MSeMA1Xn+riuvXTmeAj+CgVH Z4+Snkrrc4iOOPdcY0UlQEjO+oHd1j6ELc2Afm3LlzB9ZXPB9BtpOQkMk5wTC4pev5Oa /adw== 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=uGSnc7meAvmYJJn66svrnF7f3wlGfI+h9Tq/vU4GQF0=; b=dJohQ/HT3PK9GasMuAOPnqSNbZpJo0rAth5TMyhSSje9r7yDDNoSrw3yV1CL7JaIPk B6oHbREkWctPSpiMF8wMrL1YGdiXXFqd13VAO5Y6njBx1ihOziwDwt9bd10N5PUO0UBe HOQ0UK9CCpMhMfy9GPaGWWdqiVO0qi+pUeHrTNeWP+B5wG8/xBjKcrGnnV2yVlNhW58N H2TGRP4TXJ3y43zf3wF4YTFHyWVjXZ0ZAhrKWv2N9ikKd5XU5CgC3QdASZPaSSZ9IrJV 3gbPnh/lkiTxVIscPg1aPBa5Kxb2LszSnKYis13y+puh4lorpAH2u96zuGy6qsFULqCX 7ZXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zh6rg44c; 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 z18si5698476ilm.35.2021.05.24.08.39.04; Mon, 24 May 2021 08:39:18 -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=Zh6rg44c; 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 S233793AbhEXPj5 (ORCPT + 99 others); Mon, 24 May 2021 11:39:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233533AbhEXPfJ (ORCPT ); Mon, 24 May 2021 11:35:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B877B61403; Mon, 24 May 2021 15:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870351; bh=N88cGBSbrGgPPXU1Ft5g7cEtoFlL6nPE9ju7VKWQKvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zh6rg44cYppFgOyarQlvJXfsGIYZmXZT85iXcsFqSdGJNDZkuUqySDGy8g1VT2dLj RgZhSBVq0yfCEf/bI9/w+xYFLqrMtCIJYNdQ1N2W4UrLNykI5zkRZg6DqrF6r/So8n W6D2Ff7JOCrzWa+w5LOQw9sdKXNURmkrKFNsmgfk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" , Tom Seewald Subject: [PATCH 4.9 31/36] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:25:16 +0200 Message-Id: <20210524152325.163818236@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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: Tom Seewald commit 84460f01cba382553199bc1361f69a872d5abed4 upstream. The function qlcnic_dl_lb_test() currently calls netdev_alloc_skb() without checking afterwards that the allocation succeeded. Fix this by checking if the skb is NULL and returning an error in such a case. Breaking out of the loop if the skb is NULL is not correct as no error would be reported to the caller and no message would be printed for the user. Cc: David S. Miller Cc: stable Signed-off-by: Tom Seewald Link: https://lore.kernel.org/r/20210503115736.2104747-26-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c @@ -1038,6 +1038,8 @@ int qlcnic_do_lb_test(struct qlcnic_adap for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); + if (!skb) + goto error; qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); skb_put(skb, QLCNIC_ILB_PKT_SIZE); adapter->ahw->diag_cnt = 0; @@ -1061,6 +1063,7 @@ int qlcnic_do_lb_test(struct qlcnic_adap cnt++; } if (cnt != i) { +error: dev_err(&adapter->pdev->dev, "LB Test: failed, TX[%d], RX[%d]\n", i, cnt); if (mode != QLCNIC_ILB_MODE)