From patchwork Fri Jan 6 13:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13091393 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 468ACC3DA7A for ; Fri, 6 Jan 2023 13:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbjAFNqe (ORCPT ); Fri, 6 Jan 2023 08:46:34 -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?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Horatiu Vultur , UNGLinuxDriver@microchip.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reviewed-by: Horatiu Vultur --- 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)