Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2408105pxb; Fri, 25 Mar 2022 17:29:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR0CWgy5IW4/l5Za1Ng2pTaL2sPtEBWd7fTnmH27yX9PHSfRxWN4CW3ISsm2MYazP8gap3 X-Received: by 2002:a17:902:7802:b0:150:baa:bc1a with SMTP id p2-20020a170902780200b001500baabc1amr14390133pll.110.1648254595814; Fri, 25 Mar 2022 17:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648254595; cv=none; d=google.com; s=arc-20160816; b=EeED94VEMTR+I80ET444hBHyZ+wz2fmOd6DXk2TwZWEaMQFIJWw87sVIgRTjnI0YcI W+YDRuf1tI7on04sqwC902LU9aPyuJFNKWg4t1JKUjQbeuMJ3ulfgW9YpA2npZ6v/N2E uQFx0+pm/WQ0lJygM0jZLlfysBPWOh2jLqu/l88N8UlmJrA1DMchqZnLPVJOLWS9Kagm FgB+QX7WLpDSjXW2ngNxBdHMXXrLfdh6iFvh2XG+CsHLnZHQcp3456f9JpYQLoIwmSiw JFPdk4yzcwZxAITBhc8hodjqIBkeTpo8+Z3YZei2OupySO8xqiHFYVG47o6WPgK8hEpb eQ6g== 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=Sra84DTjE201brWQ8eofT4DMokoDMBWu7l5euKhvgwg=; b=oSOOcdotelvWdULnlLxJxU4GbdNjGV3GJYbZ02DuJszKs/beMmJmRiqnL9kR3sW5pm d4M7Pkf14nh1ePNQaO4oZVz7PRoVBEcEEE7l4XdVP8mgOBB9QAKEgIbAMrNK/pE1ileW TGRxT8n4D74KHx2lbxiHu9LSRF4wPFhmo/ZMc4rXAl9tHduBiZXw+wJmnOXMr0L2pcXL HMQwfmfw1yeEyD/hkfiCNLwN3ZiN9bpdkZeK0uFXyACCg9CqlQem0EWF78bM7aQBjp/P 9nn2S7IcVWb51lmF9+/ARTcN7CtohEB7aisq9r6PMFTkgE0w5u8SLNQvo5h4KbK18APV V7qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=IF4R6S91; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a17090340c600b001540ce7002dsi3768819pld.189.2022.03.25.17.29.40; Fri, 25 Mar 2022 17:29:55 -0700 (PDT) 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=@walle.cc header.s=mail2016061301 header.b=IF4R6S91; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229482AbiCZAFB (ORCPT + 99 others); Fri, 25 Mar 2022 20:05:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiCZAEj (ORCPT ); Fri, 25 Mar 2022 20:04:39 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 093D0F47; Fri, 25 Mar 2022 17:03:00 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 11A1F22247; Sat, 26 Mar 2022 01:02:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648252978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Sra84DTjE201brWQ8eofT4DMokoDMBWu7l5euKhvgwg=; b=IF4R6S91gD5IAM8wjUjG2NmHqv6sF16OxPyhxkdCwRdTsHewb3N9sRm4OsrLqu9RYrDFyG u+Jto63+MEOtA25hyCWhpgC1zFcBe2ZO2l6bFPXP+DZ9Yw/rNzEbSYmFEmsppLhaDlFVf5 dEbei53s7npmWGXc/5iXIjuwqWdEZAc= From: Michael Walle To: Horatiu Vultur , "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH net] net: lan966x: fix kernel oops on ioctl when I/F is down Date: Sat, 26 Mar 2022 01:02:51 +0100 Message-Id: <20220326000251.2687897-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 A SIOCGMIIPHY ioctl will cause a kernel oops when the interface is down. Fix it by checking the state and if it's no running, return an error. Fixes: 735fec995b21 ("net: lan966x: Implement SIOCSHWTSTAMP and SIOCGHWTSTAMP") Signed-off-by: Michael Walle --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index ec42e526f6fb..0adf49d19142 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -399,6 +399,9 @@ static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr, { struct lan966x_port *port = netdev_priv(dev); + if (!netif_running(dev)) + return -EINVAL; + if (!phy_has_hwtstamp(dev->phydev) && port->lan966x->ptp) { switch (cmd) { case SIOCSHWTSTAMP: -- 2.30.2