From patchwork Mon Jan 9 15:32:23 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: 13093735 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 73F4DC54EBD for ; Mon, 9 Jan 2023 15:31:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237095AbjAIPbc (ORCPT ); Mon, 9 Jan 2023 10:31:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237226AbjAIPbF (ORCPT ); Mon, 9 Jan 2023 10:31:05 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B69395FB; Mon, 9 Jan 2023 07:30:37 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CC5B84000A; Mon, 9 Jan 2023 15:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1673278235; 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=JeLio8yD9weT4NXy3rfTtYARl8N0adDQIDkmNvJp3nU=; b=mIyU7ZXDjmnd8giwcY7EM1bkXO01Tc0pmsrh62pwu6zKiJA2BV238+2nuey7QHPIuPEBYO eFwcnnqAihoAMQFIQTzAgXo56OSd1PofvhYKx2l/p1vLJy3c7LZwFQm9ZinXHz0E8dmRyW m0YAJGfDd1tAWfKP36jt7yYfCwU5rddXa3EfRhQnSrkjPtA+uepw8DcNmldlLyMd0khZ8e BkVxG9tU7yO1/i9cRdbA2NE8PvI8IWTXVHM56iIoNd69jTnDhTtvsLX3uPo5Q2LrOgP0n2 u9HrT1kssWqEFRb4JOJY7PecH+cxAV13YzV1DFwtC5gkSVWO4fqtOXLJwsR8Ig== 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 v2] net: lan966x: check for ptp to be enabled in lan966x_ptp_deinit() Date: Mon, 9 Jan 2023 16:32:23 +0100 Message-Id: <20230109153223.390015-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 Reviewed-by: Jiri Pirko --- Changes in v2: - Added Reviewed-by: Horatiu Vultur - Added net in patch subject to target net tree 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)