Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3545704pxj; Mon, 24 May 2021 09:05:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT950Ke0DVKDSbHoRYQpJHPF3lRYVVcDc1IeZUbuE2tEWK9/iJEMtyaly24IlFvdaDKCFh X-Received: by 2002:a6b:ec0b:: with SMTP id c11mr15216907ioh.99.1621872305140; Mon, 24 May 2021 09:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872305; cv=none; d=google.com; s=arc-20160816; b=WqN6NBfHOgc/oBniqb3SbOF/pEBucDH2UHQMp/LHfoW8w1T6jx0sDJGp/QUObTchzA v2tFGLmah1yLPDSAK4dIaKjqRXViD+man+PqIUMLNFSsaoliARHLBx9FFQhCu5C0xchp SwMynlRl8RRIokbF9F/e7OVdD4vLJ5ec7Y7zg2sD7NL5Ki0VOgS+Ja39NhUGFqFGJtDF 006Bn3rNz38kdMbfyBvmXogqwzXystQTuntN6LXkGuSRcSWZhaK64meSuQce2S0IIEyM 27sHFK/zePRg1V9cI1ovxGgOrsM3aJJ7j9vWgbJhftAlH4/Bb9tLGh9LyFer/Y736NKV SMmQ== 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=M1mI/HfQl4/wYhhyrqCIc9XFsK9zy/JXpIDlNaCi5i/ekLLiuZxhgNdfU5RV85Paot VP20mzSp2rZZimIW6qFswXMdze8zYzlON4lypTbQS/fhNqggggbRcz0Uonju1oYL8929 gzmy/h4sGJrGerkFe6ASZypWkpEv+F+6XK+7KXacNQbWcgpdSw546KsPkn50Vep7M5Hj Xuuoq0Cy0tmENzGg1gugDGLpmjRJQDOUS8zlhBzAvSLUGcgGxhUrsUWoqpX3SAVnRWM3 NgdO7183OF5lhy7WSNDWnPqPKFQ5WkKumuyQWudslkEoqa4zhLnFi7+YAhKpdn+ZERZL uqyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Sjy9FeZ0; 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 l15si3115280ilk.32.2021.05.24.09.04.36; Mon, 24 May 2021 09:05:05 -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=Sjy9FeZ0; 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 S236060AbhEXQCt (ORCPT + 99 others); Mon, 24 May 2021 12:02:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:41102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbhEXP4D (ORCPT ); Mon, 24 May 2021 11:56:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FBCB61444; Mon, 24 May 2021 15:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870950; bh=QZ30t+MKU3DCIDBaL96ONqEHSTHbyu3sKGvIJPTmEHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sjy9FeZ08+BF2NsP6b/cSW7K1nmhBkRbTn8AHsvBPUq2idHvoARMYrG/SVG7mIEI3 q2is6Ez8IKcikN7jWunehh0KF1Xpfqs4CZrjs/r4i1PQeYvUlhmdkPRp2hvuQ7bbqE VGmGb+uMSyzUmpIaireLfANzIFdzyCDOTGYx4a7g= 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.10 093/104] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:26:28 +0200 Message-Id: <20210524152335.930940415@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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)