Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3527982pxj; Mon, 24 May 2021 08:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO1PIM1+zJ5VIZMz94NhuHOWD0KxPiUqKpcCVhb8/pAUKJ5Pzchawh7jQCtdfBuwG+KTgn X-Received: by 2002:a92:d844:: with SMTP id h4mr14838113ilq.215.1621870958765; Mon, 24 May 2021 08:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870958; cv=none; d=google.com; s=arc-20160816; b=y3ubz4TJIsMob1Wa5X5APSTbk5pMsVgoZVNYqOCvwY4N08ItvL+3SdjaE32ouuHRVl dfojtxkVOTUyF3F8h5HBazOnl3rVeHuVAdNPr4Nyccgl2qgYRCzHGPt4e/1CeAGNMGnB pTImXv/6JwYXzIONHFHy/5XULN2l9318niEM/Q5cl1Xdh+iSV5Nu+GBMb+F/fJkLJ8D8 MYaycXHGTFLy77b32cDEr46yNuFQPGyjRjkrC5eVRY6lFcp4A81pmUMIWcK+NrwniUrm hFoLoje6NWa3jtMwakgA8WYsknFxGEvrk0zS0cO9Z89YVMqTV82xtFtB8GAUsTX5pACQ 4aJA== 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=VdnXA4pHDkCfNMch/saJaYySNaHCorMBI8w2qJdQPH8=; b=qXK3jiwGzLmkSrZnY8KFEGQAHiBDPRcD6bqtbFKXkSp587EUuJDy4kQeF4JQkl+Aaw FlYeqqJIAZO0tY/qhm1g1NBvNHAPwm8ILJ6H7LGks4MrtW4Yx0afCX/MmYk2xfCbEeu2 UVSb5zsxP2YcTucQlOWYAFZPCGNGArgtkhyJv6OHwl/rx9ANKMj417TF7i04kzI2/wa/ 29naC+8YHKbO9J+GGaN1ty0XE9Zlmjip4Edx6QN8cLdVF5ShOH6HpmO5LielG+nB0x+x crTdaqOpgnoVkQ/MfV2N2bFCNo8vK/4ohYbVijIZsFRVw1fadkFlF8hCWD4sIz8/EoOl uu6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qSEfulA7; 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 k7si14440840jaq.89.2021.05.24.08.42.26; Mon, 24 May 2021 08:42:38 -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=qSEfulA7; 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 S233704AbhEXPnR (ORCPT + 99 others); Mon, 24 May 2021 11:43:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:57092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234014AbhEXPjG (ORCPT ); Mon, 24 May 2021 11:39:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F33F61432; Mon, 24 May 2021 15:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870438; bh=QZ30t+MKU3DCIDBaL96ONqEHSTHbyu3sKGvIJPTmEHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qSEfulA7QIwJzlH42oye4rNSYj1W6xmI5cWlZEj6w99wQatrbb/YgbWmu+XG8hDQJ +whnsZ64uHF6+BSaQZqIO4h2yb7poUR38lw9Q/4Uo0tiCjET+xIbkmQGq+H73zrAaO TU6WEgWCGZjcliefALPRs/NgOJI+OoTaN5DZryeM= 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.14 33/37] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:25:37 +0200 Message-Id: <20210524152325.288499404@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@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 @@ -1047,6 +1047,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; @@ -1070,6 +1072,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)