Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3295469rwa; Tue, 23 Aug 2022 02:11:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR7jOWgRFAGpyrEseSE01WyT9hft7xYJCV9OGoUfWfqPdJED8Gj3VXmIj7rsz8kWEJAUuAWm X-Received: by 2002:a17:907:28c8:b0:730:9ccc:331f with SMTP id en8-20020a17090728c800b007309ccc331fmr15119026ejc.608.1661245864835; Tue, 23 Aug 2022 02:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661245864; cv=none; d=google.com; s=arc-20160816; b=vi0CP1/lUG7B+HAkHbQ+WE4NTUZrBmMRshgMehuDhd9imWhFfQlQ+3v5gw1AOufv6+ 8QjCU9oUPXCpUwA6W/SvRudiM40wBC5H1CiCDsWNfxWzre0Agjrip3HEfETgN/1gZmTT ULv6Y8YHlvVv7o5Vb9KUvsk0h7FiDL4NY5vslI52o8PHkRCT8vQf48E7NBENcplWUKCH NjT29RjrVBXFlkBiUuzmMy0qTgP2mK/a82vz3hFVjSh0SlswvUT+yL+0dBEcIOXMSNge HRM4bGHMFrdgy3zhKVNn9SA6cAG85G8CaSD5I9i5DhHigd0DAgbta2Y5wbibV5GdmEun KO2A== 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=f/WoIdntavq6qmB1thLE2V0Yc09e6Q2ona551SNTWk4=; b=Ndbj7s3KO4pK1JApxVSYhjA8c2BHDzYUMTcRJXHBHrd63tOmvUvOe60ALnmOjFKDce dslMcWE+QMsFFlYHE2BdPgiSZYwHTaPj7N7rQZ23VrmgpmjjTvs8i4+bkW93McrcRf5a xZiA7Ts2v663jurlUB2EhwHoFPcB91mx9MxZVXWbKun5ME2jn5x7iIzL0JFWKwR8d+dQ NVRC9Xsu1Fi/5+ewC0Pzt1LE4CZHgjcoL5wDJ7r2QH3TlAT7kLVy3Tz1ZcURxzLBj+7y g6CKlCeQP4G5qNK0Vv/tmX09BSFWj5GUrjuyjJki8gSnaK+GMZsHajEObuJ/E1/Rcg60 NS9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TuSHLBBD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg5-20020a1709072cc500b0073d87410439si3616408ejc.184.2022.08.23.02.10.37; Tue, 23 Aug 2022 02:11:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TuSHLBBD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1348015AbiHWJHe (ORCPT + 99 others); Tue, 23 Aug 2022 05:07:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241613AbiHWJGa (ORCPT ); Tue, 23 Aug 2022 05:06:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BACED85FB8; Tue, 23 Aug 2022 01:29:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 088D161475; Tue, 23 Aug 2022 08:28:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1059FC433C1; Tue, 23 Aug 2022 08:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243310; bh=RVt6G3W9mdbfkIy7nW8MAcnxPBPOKSh1h3YBa/FUnjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TuSHLBBDoAxUXEUGETPMTwTCEJrE9bn6lZlkPHRkqSbdAecO3sgGg2TMgXQ9u5N/g RTOp50UXmeIMt2gCOD7pGdc2BeuOaoue6KqhzGNrvYYKGlY0+MFLc4peF7stMGn+Hw +SNP4im8UJt/X37wrSqEeEcTK5OoFn2IxACiPYBQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vivien Didelot , Florian Fainelli , Sergei Antonov , Vladimir Oltean , Jakub Kicinski Subject: [PATCH 5.19 206/365] net: dsa: mv88e6060: prevent crash on an unused port Date: Tue, 23 Aug 2022 10:01:47 +0200 Message-Id: <20220823080126.818158646@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sergei Antonov commit 246bbf2f977ea36aaf41f5d24370fef433250728 upstream. If the port isn't a CPU port nor a user port, 'cpu_dp' is a null pointer and a crash happened on dereferencing it in mv88e6060_setup_port(): [ 9.575872] Unable to handle kernel NULL pointer dereference at virtual address 00000014 ... [ 9.942216] mv88e6060_setup from dsa_register_switch+0x814/0xe84 [ 9.948616] dsa_register_switch from mdio_probe+0x2c/0x54 [ 9.954433] mdio_probe from really_probe.part.0+0x98/0x2a0 [ 9.960375] really_probe.part.0 from driver_probe_device+0x30/0x10c [ 9.967029] driver_probe_device from __device_attach_driver+0xb8/0x13c [ 9.973946] __device_attach_driver from bus_for_each_drv+0x90/0xe0 [ 9.980509] bus_for_each_drv from __device_attach+0x110/0x184 [ 9.986632] __device_attach from bus_probe_device+0x8c/0x94 [ 9.992577] bus_probe_device from deferred_probe_work_func+0x78/0xa8 [ 9.999311] deferred_probe_work_func from process_one_work+0x290/0x73c [ 10.006292] process_one_work from worker_thread+0x30/0x4b8 [ 10.012155] worker_thread from kthread+0xd4/0x10c [ 10.017238] kthread from ret_from_fork+0x14/0x3c Fixes: 0abfd494deef ("net: dsa: use dedicated CPU port") CC: Vivien Didelot CC: Florian Fainelli Signed-off-by: Sergei Antonov Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20220811070939.1717146-1-saproj@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/mv88e6060.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/dsa/mv88e6060.c +++ b/drivers/net/dsa/mv88e6060.c @@ -118,6 +118,9 @@ static int mv88e6060_setup_port(struct m int addr = REG_PORT(p); int ret; + if (dsa_is_unused_port(priv->ds, p)) + return 0; + /* Do not force flow control, disable Ingress and Egress * Header tagging, disable VLAN tunneling, and set the port * state to Forwarding. Additionally, if this is the CPU