Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3536734pxj; Mon, 24 May 2021 08:54:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT7ThtKpS6MTrRmurACwWM4iXQjUwCINBQJQHZ37ar51fgNK3uZH9gLf8JBemsh7h6Xtfg X-Received: by 2002:aa7:dc15:: with SMTP id b21mr26917548edu.350.1621871695629; Mon, 24 May 2021 08:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871695; cv=none; d=google.com; s=arc-20160816; b=ou06Zg3T+deJhwQKsySOanLlEMIWA947y6TKSMx6sZqQqnSC5MrQbyzhcrPATrQrt2 bvFoGsimC7h5qALEZim+DC+4y3qownVnKOzB7N/w58LuKsgxYZQG0kxfcWrFlSE/y+pV rhdAXb3i3jh2zVKgzqZoOm8dk3/FGQ2PvtAZpiLaxID9m6ZYZ6av+e+uEAjF4EoVSI9I 27pWKz20cWUNS3/TVO4DU3AFabQaK7FSarbgkR6pxH2/HzUzHbZul91MFyeQt9rJNll8 gxRLcSfiKG7WpN3723pqeQKrSPi1UlwcM8Ync1A9rCA+1qmw3uEqZVIqVEbuRAzVsIdr nFDg== 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=Mn/g8cKO/aLNPa4kJjgYyFPZzZNLDx3KXwWfTNcDmRcGVEa79ySEwpPv+Hv0oWwWZI 0btgdOUSD1lKY5vYSaUkEkN1+VAeTr6O82zrTMZMdBY9rMYiVgHQQE6VGTh4KjDrx/oY /0gtBaU1Fx9HXiYxJMlmt3IaQfTBeMkexzo1Mjl+M4ZO0tM0nS/r5N+lfU2KeUr2oIqd M0D+morFNTKkeaR6DteLNTzT+ksBQhquX7jBTh7myI/Q/gR57TPI8L2DvFkEka4kH106 lQuQt1rIp6jjoZfG3My9iapiE0Cc7VcQR+mS+WZ3EeFyD0H8e7x7eue1DYKBeWOwGgBL 9fiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SjWPflEt; 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 yh21si17728936ejb.150.2021.05.24.08.54.32; Mon, 24 May 2021 08:54:55 -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=SjWPflEt; 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 S234870AbhEXPyu (ORCPT + 99 others); Mon, 24 May 2021 11:54:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:33936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234631AbhEXPo1 (ORCPT ); Mon, 24 May 2021 11:44:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4150D61452; Mon, 24 May 2021 15:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870564; bh=spKPCrO0sL/Gh3g1hk1TvU51aq5+aqlImPb+KmLLB0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SjWPflEtIHCbNcU4V44kQAdXKLRzxt697qeKFJlY9VAXvqzkCRzmVO2IcSmr338ox nMArdJHHcO7FhBljzY8kCTlFPgRPDwUqmu14LpSMwaOZVjSd3GuFiLeAqioNwtckhB YUat59bikoW7h5JgzUMDyPPPwH5/td4FEjDOO4NM= 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.19 44/49] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:25:55 +0200 Message-Id: <20210524152325.791989205@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@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)