Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3539079pxj; Mon, 24 May 2021 08:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxPMW95uKMoPxYV3hKlGrlGw6WICoHH21hajEAjCHd0e+xjRjNWf1IaRUA2CPx2VdyKgz3 X-Received: by 2002:a92:dd04:: with SMTP id n4mr18159299ilm.165.1621871880346; Mon, 24 May 2021 08:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871880; cv=none; d=google.com; s=arc-20160816; b=MFXdg53BAdlO0vEJsbMgweiCcIMn81jT4vigN3QyFyVlXFX+3/vAjjVvR2yH59sI78 qymHB/jJAcDhwGObUyGkhay/kbcDrq0z8sfkDUl5Vx4PVnr+o3wEWOfTFnAs/XzDZ867 DVfbyttNghSVeMRp8uZ9Zawbx5qmIw8iTzwErUF/xiE3w+21Q70OlZqqEbOb3XSe+phs 7Fe6AE1XfyPGHaI43Xv8ZWU6gDohzYdBU7tQvPAtlufPgyxsCnreLmXFXuJABc/M1g6h mO5xwVo4rwuobeWGbV9ysfwWOmOQfh+h4rYKwmrmbf3Lr9H6vYHNPJa1CYWz9B5HT54S 60WA== 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=/L9y7gisQaj76aeXOsM9Bcw6Rq07U5WMA4+qnuGDw/o=; b=wMII/oP75O6UXxE9lgdUDoHrHggLxDEjQeg4/WAHVTEUVY9cN9vJFhq/1/BNM9VeAV 9wiWc12tUt+fURvzJpqCrYshbByVHleqJnDyResn9zfNGl5jLKt+hmc9i9pc8Og7hy+g s3pPZy1Zo5QZcRsSUiVriOeO1iGt78Ha4CVlf82UU5JPeb706QJOdeelYAt2qaEs/TlF YItUVdlacGywQg7vi1kgLpgidWVRRW3iHW2AIHsAEpcfLLpZMOXwsmzfkv1pqdNNavcf c2hMZra0eHvQp8+qJtNdrIRDpsDhppAw6lhQlPh2pUpVa/laB95CPXtgzAtun2s3bF8G vZzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fZTaQewk; 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 d8si14254018iob.68.2021.05.24.08.57.47; Mon, 24 May 2021 08:58:00 -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=fZTaQewk; 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 S234005AbhEXP5R (ORCPT + 99 others); Mon, 24 May 2021 11:57:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:38714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234893AbhEXPuN (ORCPT ); Mon, 24 May 2021 11:50:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 935606161E; Mon, 24 May 2021 15:38:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870695; bh=spKPCrO0sL/Gh3g1hk1TvU51aq5+aqlImPb+KmLLB0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fZTaQewkMrGlaXv1IeOVrQj23wGDgmewo1Htx8XDCZ7dWof8xP3O0aqGMfws4pTFE 5iMnIBrO+6CulZGZuuo6lqPlxN3oIT4HiXwpa8I8qVVULxFAFLeCXwzeODXE8frzDp pSOYwUznJGjq9qkrp9Eg/qKQvl2zZ7Zw4hqtqF2M= 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 5.4 64/71] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:26:10 +0200 Message-Id: <20210524152328.527988567@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 @@ -1048,6 +1048,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; @@ -1071,6 +1073,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)