Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2420206rwl; Fri, 6 Jan 2023 06:16:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXtoOypJGgSCrc175y1ACJapX4EHNg5G47Rb/visnrRbK/aHbZpD6eTbr1w+fMA2p1Y1O3zG X-Received: by 2002:a17:903:1cd:b0:192:b52f:33bb with SMTP id e13-20020a17090301cd00b00192b52f33bbmr36748081plh.45.1673014599679; Fri, 06 Jan 2023 06:16:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673014599; cv=none; d=google.com; s=arc-20160816; b=fX3H/g0Rwqc0sfR++fXtaJeeERNcj/UfjiXwAasxrNGaYgADcxnaKoZdDi/kg6Y5eN 8Z/0jyPy9cGo9RZePdyKQK0nUKQitbGbD60OgdGZDnNjHYnAmhDbe1lrxa88aa9KLGk9 bmFt/4RJ8EbgOmC5nSwUrKom2uo4d6hD5dQzsII55tmOp8Eqrt6cPp9wp+PIVpOj8mQF FII40IgMqGUELtYXPU/t41Csibqn7i/s3qRlscdbzwH3xfsPXMyLfGKXDs/MSEHXPdDg /bUKBM7FHGSQsgq5aMCusThUJpOGw7bfy0zjZcIbbmjTBa1g8zIuC4xFMDlYRAgdctV4 0xlw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uu7OlXq7ioXd41G8rKLySQ2P+vBgHgZaa7tQBl0hBPY=; b=XN7vRMIugkJLlt61E2V/sRzeOaFvs2TPDbDXz18gttMzye4soQvIZllOUuUDq0gPe3 mp6muBpfmCXgv2hSsBX25yLQfLT54jwfDuMGkMYYYmf3sa5js6SgO1L8LqNsqaujWjEY GaShPHkBqogBjpUUB9i5scFpDgLkf0ycI/PlZzFWLOhIiqSBzu2l8jZbk8BeEYPGk916 kzs7HwzZDrnX97kIc4dERd9Xm/k/m52KrbwdiBO+hnRINdRL1IHWG1TUuUusIlTuG9jz 1bRG4eqe+KMRGYNofYdQ6KXfMQh+OIa4hwFz6HaoFMbXHQ6HfYG2Nq+Az+YNUqnXYoAg ehQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Jaw9EnR0; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg17-20020a17090326d100b0019317aff5f1si86620plb.603.2023.01.06.06.16.31; Fri, 06 Jan 2023 06:16:39 -0800 (PST) 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=@bootlin.com header.s=gm1 header.b=Jaw9EnR0; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233789AbjAFNqf (ORCPT + 56 others); Fri, 6 Jan 2023 08:46:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbjAFNqd (ORCPT ); Fri, 6 Jan 2023 08:46:33 -0500 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7282631C; Fri, 6 Jan 2023 05:46:31 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B2E21E000F; Fri, 6 Jan 2023 13:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1673012790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uu7OlXq7ioXd41G8rKLySQ2P+vBgHgZaa7tQBl0hBPY=; b=Jaw9EnR0ocZijcz73Weg51q15VpvtxO+e+sXj6TECPVfvS4t3CG5IsZSMicIGkphQrAJSR RMrI3V7yfPAys2mACw6z6a+ushF4tqEH4dunx7gWqcVg/uT6M8iAg0KNEc6J3jbaD59sTa 3Yx2v1Ii98pZFw1Wxislma4WLuAutaL7UBtIKJj2UCAf0wFbKJa8uJjzVNaK5RwMp3hAAu OshQODbT3gloiCkutv+o/Oq8gMcApGoz3lwMZubM3NJ/jBLTNHFbA0cKRbXnHGof6X41OP iwmWHJH+Ch9+0dR4fj652hMw24AqzL3JkUDNbUic+BdzyLmMApom/hc824K54A== From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: Horatiu Vultur , UNGLinuxDriver@microchip.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: lan966x: check for ptp to be enabled in lan966x_ptp_deinit() Date: Fri, 6 Jan 2023 14:48:30 +0100 Message-Id: <20230106134830.333494-1-clement.leger@bootlin.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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 If ptp was not enabled due to missing IRQ for instance, lan966x_ptp_deinit() will dereference NULL pointers. Fixes: d096459494a8 ("net: lan966x: Add support for ptp clocks") Signed-off-by: Clément Léger --- drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c index f9ebfaafbebc..a8348437dd87 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c @@ -1073,6 +1073,9 @@ void lan966x_ptp_deinit(struct lan966x *lan966x) struct lan966x_port *port; int i; + if (!lan966x->ptp) + return; + for (i = 0; i < lan966x->num_phys_ports; i++) { port = lan966x->ports[i]; if (!port) -- 2.38.1