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: 40927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2220847wrt; Mon, 9 Jan 2023 07:33:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXsMrV2N1NKXjU3vr14J5AHvagGTnlAOTxhuiBlBrCIgv+sRpKeoyvhS3uXc3JT2v7YQtYAX X-Received: by 2002:a17:902:ed11:b0:193:38a1:68e4 with SMTP id b17-20020a170902ed1100b0019338a168e4mr1651945pld.0.1673278408401; Mon, 09 Jan 2023 07:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673278408; cv=none; d=google.com; s=arc-20160816; b=TRwPY7lpu7aTC98ev9SjVEfkjHEPpjGSWrfQED0PgyjCkQiFjUV82qCY33OpBGlVVX HuExbr7wJBaFXhwz9/Nh5ylGl8DYuH2ocx1qFhy/6ItHhaekFXMct6tNX/2Os5aC+zVA e373dlE0jLsmk0el8NXNnAPWsHoROb/n0y9d2tKWyKpLUj6vBcjbWvUrsviNruWahCwA 4bYBIXY3Pwew4V+Wp1lQL41gbgVU9q1+1RrKUAIgvtbCdAOi30Tc5xRfNRJwiCBcFAO2 4K12YvbA0OZWL9brm0b4QPkm4t6UmUTaoxL4tMbtqJhoxKv/uGuhviHrMVugU87CZLqI XSQA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba11-20020a170902720b00b0019329597730si4919392plb.378.2023.01.09.07.33.14; Mon, 09 Jan 2023 07:33:28 -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 + 99 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?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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754559580566264657?= X-GMAIL-MSGID: =?utf-8?q?1754559580566264657?= 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)