Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3335515imu; Sun, 11 Nov 2018 12:38:20 -0800 (PST) X-Google-Smtp-Source: AJdET5dfuqh32F/vGUORpWCdX0FyMKG9iHYpvYXH9CDqgEA0kTqOqHKZ2TNsu7E4hI+Q5qlfEebi X-Received: by 2002:a63:8742:: with SMTP id i63mr15013997pge.298.1541968700469; Sun, 11 Nov 2018 12:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968700; cv=none; d=google.com; s=arc-20160816; b=fxIPhxjEcQTCKwzthaVztP6r8cZnTSmCg4wiECjPiLPUw53WZwDfy1VwhEjS9aeN3F ETya5fk35bBSbGjGz5NjUsHPn/XhBohCpIzf+SWSBenl4GxdaINJZ7eeZh4zuzMhZypG gb5P2/KCjDoSgfhxQcGD/Hk/p4CwlkCRpwN3Glqr5VgxlSqaL/0Km9qC0eeJPm5f+ExE KRIo3u/97k8tfz3J/P+VUq8Sf+KzuTjmIQMNZ8XCQDBm/bKGyDiy3dq8/6xkh34W+XRc 97Y+498zeZ91Tykf9UGArXUYkYVCE6e6P0XJwJDq48sFYLn5Fg37BpFUZM1dkmD8xwG4 SKdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Md7c+CWYL2v9aMe3O8iWV+m3l+4OXsR2otQ7HVk+/K8=; b=AyuFWtNg/p71EsBHJ8QuZoFY/A0jvf+BjQx5u+OMOo2+v3mF59cbpx1sCRAFCAY7x+ Qjl6Yx7LPI12DT35UhTS7x1eivbiL/M/00D+48Dj0cZdv6fRD/hkeSAHoJN+OubRmdAH YUOPQB63nxEBmkng9J4X5YbiNvvqqaDy60PnnVQRtSN7Ug76bVr1LCWJ05T4tNDLzK67 95EIYMtaTR7JFUpEbs2tLm7a8fc9VkbFeLe1oDYZiHxzEOvkB6wu01PYGZCtB4kJWCao avbYDMFGuq9uVmzrzFcSYfPF+94SPi5/b6GMJFgKICloiPSwLXXINDLA3mXktpgngGMp nIBA== ARC-Authentication-Results: i=1; mx.google.com; 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 y5-v6si16174128pfg.52.2018.11.11.12.38.05; Sun, 11 Nov 2018 12:38:20 -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; 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 S1730087AbeKLFsK (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:10 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49656 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730053AbeKLFsK (ORCPT ); Mon, 12 Nov 2018 00:48:10 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsW-0000l8-Bh; Sun, 11 Nov 2018 19:58:40 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsT-0001bD-7q; Sun, 11 Nov 2018 19:58:37 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Chas Williams" <3chas3@gmail.com>, "David S. Miller" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 169/366] net/xen-netfront: only clean up queues if present In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Chas Williams <3chas3@gmail.com> commit 9a873c71e91cabf4c10fd9bbd8358c22deaf6c9e upstream. If you simply load and unload the module without starting the interfaces, the queues are never created and you get a bad pointer dereference. Signed-off-by: Chas Williams <3chas3@gmail.com> Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/xen-netfront.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1422,7 +1422,7 @@ static void xennet_disconnect_backend(st netif_carrier_off(info->netdev); - for (i = 0; i < num_queues; ++i) { + for (i = 0; i < num_queues && info->queues; ++i) { struct netfront_queue *queue = &info->queues[i]; del_timer_sync(&queue->rx_refill_timer); @@ -2294,7 +2294,8 @@ static int xennet_remove(struct xenbus_d unregister_netdev(info->netdev); - xennet_destroy_queues(info); + if (info->queues) + xennet_destroy_queues(info); xennet_free_netdev(info->netdev); return 0;