Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6392243rwl; Mon, 9 Jan 2023 07:49:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXutQQew9KndMzdAduOJ9wONvcSLsr7hCn+lLpW91Y4WKf0VbpDXjp3rSDg1orl11RXqCmA/ X-Received: by 2002:a17:906:36c5:b0:829:594c:8ec8 with SMTP id b5-20020a17090636c500b00829594c8ec8mr51181581ejc.29.1673279365114; Mon, 09 Jan 2023 07:49:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673279365; cv=none; d=google.com; s=arc-20160816; b=sd2cLwTjFs+jTWqNwDUx1CWgTCLT60muZaUamsMUJ0WhHKAa6BSoDf+sxxlYeVV43X M2p7ZA4US49UbA+tiIqULEAz3/SU31kigrM9MJUOs7/g48S9/D7BJXliDALW8laWEac2 I2h/IMx/25TPNWJhK7GVvAy1ou34xRc6D1Nt7cXDO2TM4doqeNmzZ6bbh5QB7AZoWmix 2TsNBlI6HiJK2jPH7xuG0m3sxKwQoTkIJXs5pt1u2F5lKBUuV5+DwxhZXVvObvKHG++9 6FztMOr9YJKPlt/2jDmBWE6Z0Xy1dv5yOmALh1DktsAlXStAnA6gaLvHkOGiumdyk2dh KUSQ== 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=JeLio8yD9weT4NXy3rfTtYARl8N0adDQIDkmNvJp3nU=; b=WPaXnT4Zgt5U+nLMoAqATrEQQUTLpY0AUaeiJwv3j/fb42UUxPbYnDHNWv+uPmY+T+ BNgN/HVd+qHvkezuoBgS0mmlMl67QD6PEkIFxkvY8EZwERfj2oX7FFjOCfsrQtFdTLFy 7gKUT3wYYWiapylpjscmRGAdb7fDFF1XnEFvx3KCDhScEGswlvzqQck2R+uXvOtpGWon 86yLececr1YHJutD1PtuTSyj/E+aL2QPJ4n3nTlBWl+Cps8NvSAG1AGJ+5L2xmINFK4k OvVRcoaXGniPQAIcKoeoVEjinfDUhr0fQCBZxM5BEQ8FetG/D8eaiXGqjcrrMjNfOda1 RC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mIyU7ZXD; 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 wv4-20020a170907080400b007c10bb5b4b3si9911757ejb.681.2023.01.09.07.49.12; Mon, 09 Jan 2023 07:49:25 -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=mIyU7ZXD; 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 S237280AbjAIPbd (ORCPT + 53 others); Mon, 9 Jan 2023 10:31:33 -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?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 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 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,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 Reviewed-by: Horatiu Vultur --- 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) -- 2.38.1