Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3551326pxj; Mon, 24 May 2021 09:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWKFyXKX9wqg1PgHofzvirJf3KN7kRgZcsCv3ucxTGENi6atOJoGj5+CbZCxXqVNJehbns X-Received: by 2002:a05:6638:22b4:: with SMTP id z20mr24549956jas.128.1621872677044; Mon, 24 May 2021 09:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872677; cv=none; d=google.com; s=arc-20160816; b=rG+saZPQ+hBOnoxCPH9fbREJyl+Ts3nbQmPGxUHXe2FBidJyc4NbNkElLGN7aUxcsk 7NjTI3SuS9dmsDVt+K64+40P1vN/PhQc4+CP2/JfB6aIeKmo8SlJs5vDl+z8RKdOdqhu Qdf6XoVbf5uNJ+6by9obgUN08Cy5KI5DLFUgAAWQHwjS1vlBq5VdwcoMnQFMZwKBg8s+ O95ES0Ep7SklV73DTV7QTPYE5oRoSEXAlkl2qwJO1RrC8oi30pf/0CpemE3wfa0bqqf2 e0L/JQzGd7wJN6f0LN8iUvTPVqsK4pxVuormYayPEZpC9Sh7U16sfx3E1Jp92qfS9SHc CThg== 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=B+O6DvfXIfcW/5AA9QfeJFOW7lnbpNVYGoqvCIV2yBnnpDPowRz1thkf+ZaJ/BsNXg YY48uelr38G2KIMA+gc3qsgYUcpBYsXFVBSAjbr6cfovldmuAKozdLlVWl8fH2XWMV2V iwOThZjuGipYJEAAm4a7cPd6yMiWvfjSNjOh+Mr1QGtTH5/NQudZovOzd8LJWOUPidIi y9os1be0LO9071okJ2K4GQ6BBwDGEmtaT+eAvp7dgS9GAu99U5udOkoP0r7ACXgWQOU1 5QojJ+Nwp4PpXArfDEyOxYN1lzbN8Xb1jdxkB2nAA1J6poWBwN6XvnygDG+b39FxCCSA L52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s7gRtOPN; 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 g11si16655965ilf.108.2021.05.24.09.11.04; Mon, 24 May 2021 09:11:17 -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=s7gRtOPN; 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 S237840AbhEXQJT (ORCPT + 99 others); Mon, 24 May 2021 12:09:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:45006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235565AbhEXQBA (ORCPT ); Mon, 24 May 2021 12:01:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B911461988; Mon, 24 May 2021 15:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871192; bh=QZ30t+MKU3DCIDBaL96ONqEHSTHbyu3sKGvIJPTmEHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s7gRtOPNtzl5hY3AjMLi3+0IOo/sJH5tiE2newCSw3FBb86tLfYd6BGCJ/SCirfTp HOtrexUpd7Xw70iQftt8EJaxc0U3B9pi9eL0XWbpYEqfM0UnCFMA0Hw6FWFKRPiTEM eVWlTPnIA4kIdu9+Aowf/+JMD8bVhRQrB/jomn34= 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.12 116/127] qlcnic: Add null check after calling netdev_alloc_skb Date: Mon, 24 May 2021 17:27:13 +0200 Message-Id: <20210524152338.784750752@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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)