Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13474592ybl; Sun, 29 Dec 2019 12:47:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzX01H6YK7oJzzdzT+gQNy7LXWxRsdmcvYkh68z4hx+Dun6VYLvrHcaATMfnr4bvKkyx52W X-Received: by 2002:a05:6830:1e16:: with SMTP id s22mr58828767otr.340.1577652445873; Sun, 29 Dec 2019 12:47:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652445; cv=none; d=google.com; s=arc-20160816; b=DM8Y1NzGC8xIKj3JUEbO2lIqypvH+alBfbp7dKSwx0goEMngJKdlq7H5f0RBjvXJho 6EP6WccEWLn5P5fRUuBSOaP/4WE0dRahZ3I29umMgANLeRSOiHUGrWF9Jpy2jm7wjywT 2Y8IEd0tqeZkqKByKzDMpsORQzDPuv/yU0Auvx36z/DIWXo02gnMjJxcNyLtfbFZnIk7 ynEKftzYqZhrJtMbY3KKP+SVe01P4sxQC4rTnNByzqFUiOPpwAUvMGf4J2i9J4z71obu C1qTJIcdqNk8QgoXEeLWeBv4wPuoDp6qXgkWYHoC/wSRIqTm+oF4+Nb7INkjdlDeAbEq leiA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zX+jNoPHv46V+QaSaXn3umSFx+RyXZNNa6ssck0jMOQ=; b=ihtFNTRhjTqHVQq33nk1sJAB05Cixy/10ArrOv8QpZTJ9h6jdvNP8rhv8MYw0crWQq OwsBq5lWXKLUB2aoJhKg6VYyY3dc0pA3b0pbgoK4a50pn6Zwpsr0LCDoRWjfV5CFt7pR 98ZoaX3mdDq4w6G117sKVVOYjbymk9wnsz8thQvTLX/Gp6jWdnHNzL3H2wlBPmgoeSWm b6Q1uSShoCU/e1dSEP0exEWflnpb9h7cTVLWJc+zlTl5qD5IgFir/dWpWrgLECM7A5ia 4XD8v/EvgWQecAGW2jlaGLSzusmiPsNhVQUyanb8nU4/pZ9RVBAkKt6tOcrm0DWvGvC1 r2tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ijf7pV1k; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u125si20816420oif.130.2019.12.29.12.47.14; Sun, 29 Dec 2019 12:47:25 -0800 (PST) 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=ijf7pV1k; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732147AbfL2Rvo (ORCPT + 99 others); Sun, 29 Dec 2019 12:51:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:37240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732130AbfL2Rvk (ORCPT ); Sun, 29 Dec 2019 12:51:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 366A5207FF; Sun, 29 Dec 2019 17:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641899; bh=xfqAEOXP8WL0uY3FmB+kfUgO7QT/ivSS/iu6YVabdDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijf7pV1kP/X9CAzU/655USn+K+VDzynTXzkOXDP1rn2kuPmJVrR1Od8fx/aFgG07G yCriZ2OraYFcS/KAuzEVfyIqBtDcWEOTW+oGsnyZC5JhMTDSke3xPsB0IGxBgtr3ga QEZgUkYA3zxPg1Vx1D/8bAUE3i1ikUFt5NPQ+TQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Swiatkowski , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: [PATCH 5.4 258/434] ice: Check for null pointer dereference when setting rings Date: Sun, 29 Dec 2019 18:25:11 +0100 Message-Id: <20191229172719.070656145@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Swiatkowski [ Upstream commit eb0ee8abfeb9ff4b98e8e40217b8667bfb08587a ] Without this check rebuild vsi can lead to kernel panic. Signed-off-by: Michal Swiatkowski Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 214cd6eca405..2408f0de95fc 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3970,8 +3970,13 @@ int ice_vsi_setup_tx_rings(struct ice_vsi *vsi) } ice_for_each_txq(vsi, i) { - vsi->tx_rings[i]->netdev = vsi->netdev; - err = ice_setup_tx_ring(vsi->tx_rings[i]); + struct ice_ring *ring = vsi->tx_rings[i]; + + if (!ring) + return -EINVAL; + + ring->netdev = vsi->netdev; + err = ice_setup_tx_ring(ring); if (err) break; } @@ -3996,8 +4001,13 @@ int ice_vsi_setup_rx_rings(struct ice_vsi *vsi) } ice_for_each_rxq(vsi, i) { - vsi->rx_rings[i]->netdev = vsi->netdev; - err = ice_setup_rx_ring(vsi->rx_rings[i]); + struct ice_ring *ring = vsi->rx_rings[i]; + + if (!ring) + return -EINVAL; + + ring->netdev = vsi->netdev; + err = ice_setup_rx_ring(ring); if (err) break; } -- 2.20.1