Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2234568ybi; Thu, 20 Jun 2019 11:19:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqm6oSyrQ2cJGKKuwvW5x7r2dI+6xEhTu5VNf93EXpxycwRCbRS51ThfKY9v0JjYI6ic8k X-Received: by 2002:a62:b503:: with SMTP id y3mr9944235pfe.4.1561054792022; Thu, 20 Jun 2019 11:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054792; cv=none; d=google.com; s=arc-20160816; b=dSAqGqtS7rBvTfEl1IjC+Z/4WL2UsDs/Akx9lsuyG+884cdCxby1NdmNs4tp1fpxFa m5x63d1OjbjUTk3YWhjAcrp0jlQk3UDuDs92WBDH7QTqPuOjqG9FIeYG+erVUg3vL8GL bmCdsSQ/XcW3J/Xt94ld+W48NTAZOUhb1biq0FVO5Bo0FPSZ/y5eT2NJaGLxnEvT7JCA HHlEJc7AkxLE2azkiuu9soBdzZ1bBzXVh5jcMig/l1AT3A+50nb9Ybnt1xXM8roorFrk GydkWOUCir+OYt3DJBAUmhD8GzK0E+Tud7lmQBbkDHOLcS7LFyizacQu9ECpjxKEU75h N0pQ== 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=OTJ5DXW2fo1cY1LUXtS7g6z3oOYp9XN1JDhZHf1nReo=; b=gyX8P5Pq0rGVLhSmio1M0Mfbiyo81/D78FC6JqPFpFFyFK7GUl9c4WKO16G3me7hfK J21+ZRTxoP4pk9eowsvq8HsJQjcx1BLasgPQZ7hPo3GH01mK0iYRKINt7p4rqSwPcBla T3XDsXSmbIZ8WEdoGO0yXpMHY6PA4d7NvvSl3tC20dm0slJQMi616kmvK5v6HXVJH5Mr qd+4E93DPljof4XyCOwW8Y0gPF5mGjk3Dmzj5T2y50j5jlc3C03lk/Px6juWrzswcWvv sRIA28gsE4mB1CJUxNKj7/0AqSG4u8hfUEnnexsXo3LTbVr1CdKgEQfqD7jTAjJrJEjn F50w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yqW9Qzh/"; 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 m6si430454pjl.60.2019.06.20.11.19.37; Thu, 20 Jun 2019 11:19:52 -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="yqW9Qzh/"; 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 S1729161AbfFTSPF (ORCPT + 99 others); Thu, 20 Jun 2019 14:15:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:43594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729531AbfFTSPC (ORCPT ); Thu, 20 Jun 2019 14:15:02 -0400 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 273C72082C; Thu, 20 Jun 2019 18:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054501; bh=49ezs3/aU5lyBfud/X1bg7oOESx5cpNZfLmlGK7x1To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yqW9Qzh/o/iRYzAzoMEyVP6c+cLcvWG5XCWc8NXsI18qb+iH7Nj8QtdnpArwqjvnb KZJdi/22QFz+R8agWXu5q74wGWmSKhgKAyPr51/xpPYGr29zPNBsKw2BxPii9trV4/ s/ZJ13LcL14IvJ/1ju5x5o86Ct5vQ/lBnEljwrJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Hancock , Vivien Didelot , Andrew Lunn , Florian Fainelli , "David S. Miller" Subject: [PATCH 5.1 21/98] net: dsa: microchip: Dont try to read stats for unused ports Date: Thu, 20 Jun 2019 19:56:48 +0200 Message-Id: <20190620174350.185106211@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@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: Robert Hancock [ Upstream commit 6bb9e376c2a4cc5120c3bf5fd3048b9a0a6ec1f8 ] If some of the switch ports were not listed in the device tree, due to being unused, the ksz_mib_read_work function ended up accessing a NULL dp->slave pointer and causing an oops. Skip checking statistics for any unused ports. Fixes: 7c6ff470aa867f53 ("net: dsa: microchip: add MIB counter reading support") Signed-off-by: Robert Hancock Reviewed-by: Vivien Didelot Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/microchip/ksz_common.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -83,6 +83,9 @@ static void ksz_mib_read_work(struct wor int i; for (i = 0; i < dev->mib_port_cnt; i++) { + if (dsa_is_unused_port(dev->ds, i)) + continue; + p = &dev->ports[i]; mib = &p->mib; mutex_lock(&mib->cnt_mutex);