Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2843239yba; Mon, 22 Apr 2019 14:06:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYMQqy3sZaY36QIi4ts20nVgmmV+nTPhW+QgUxYdREpwINVabE5ObayRgRRZAxFOwuxjKJ X-Received: by 2002:a63:e045:: with SMTP id n5mr19922749pgj.230.1555967199800; Mon, 22 Apr 2019 14:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555967199; cv=none; d=google.com; s=arc-20160816; b=fbSKYW6RcMssUOmzldWWTzKsjYN8FA7rFmDDikW6+sFjMx3EMFMJgzTbBpRKNRYXoG +fJrBLzQVq65H9kdcEes/6h8GYAxD4utRO2TJD3fj44RkROiJnmbndRk7wKkQ7gxfjO5 1FuN+2wmX3yvK3BcexrJcZIjBtiYkSYhLSF8K18engDByQZcl/LVz3842mZL4vq70n8/ oJx5by01mhTd3easDuMOWaoliLvTmGFiYzXSxC0wLd72ut0cD2hnccxPSfnMM/lpGoHn dhuNUY6lE+QoiQBuWuh3bXn6tyg7O3tTw75pip3V5V+NhlgzPNoDS5bdLKSISRB6Rmy+ 2KZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Dr/3UXhK+BM9F1NCPvUd92qYRTtm1xt9pFJUbeL5i1w=; b=w7ayNy9GjJrGuvSJfOiUbdOxK3EIDEGIdGN0w0b53EVKaqH7zCjajDKWvBcvqMQw2+ v193buyyRz1KncLwVSvh1NotTOrXJ4QnWW96GXqlo62lBfAnByZsH11w0qzpUR0+4Hng bIRupOf/wQyJn+z3eM8ufJykiOG6Zx9wWFfVasmYkXhi5PwS6W2v4t9Lrly6VMapC2GC /zZw10L9dVFNwQREP039KKMX3aYGVELcHllw2+pYyR7OB2xPQL7A+2E6nxzAaWL3soN+ GDN0oveFNBe05tipg+IUaZUFYfQfWEDhD0wpuT+CtjveBq9Z62c+0Yk4HTbSxslbirmV Av0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gPghD89I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si13949057pfh.244.2019.04.22.14.06.23; Mon, 22 Apr 2019 14:06:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gPghD89I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729786AbfDVTpe (ORCPT + 99 others); Mon, 22 Apr 2019 15:45:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:47220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729732AbfDVTp2 (ORCPT ); Mon, 22 Apr 2019 15:45:28 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD8BB21904; Mon, 22 Apr 2019 19:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962327; bh=XAzFXlP87E7U02nFKK6K6OOe5SvtJALvL1QYzYr23jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPghD89ILPixmHttRQTp8F0PGCCUCByenA8XJUvHVUQ85e2z9qSZIhf2vFm9xvpFj F1Oz3plIXM4IqRHsiQV9+mLRlocsu5tDXgr0poWuIooID7hAwRawmatOCyGJf1uJa4 ns4gWnLn6IWgTDDZxhmS3Qmbioe9KQSTzFvvC5+I= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aditya Pakki , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 06/68] qlcnic: Avoid potential NULL pointer dereference Date: Mon, 22 Apr 2019 15:44:14 -0400 Message-Id: <20190422194516.11634-6-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aditya Pakki [ Upstream commit 5bf7295fe34a5251b1d241b9736af4697b590670 ] netdev_alloc_skb can fail and return a NULL pointer which is dereferenced without a check. The patch avoids such a scenario. Signed-off-by: Aditya Pakki Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 3b0adda7cc9c..a4cd6f2cfb86 100644 --- 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_adapter *adapter, u8 mode) for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); + if (!skb) + break; qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); skb_put(skb, QLCNIC_ILB_PKT_SIZE); adapter->ahw->diag_cnt = 0; -- 2.19.1