Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5656724pxb; Mon, 28 Mar 2022 15:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNLBgifvFiQCjIvNaQ8EfAnNLn+9ZSQmGJ335FGV0HJF90YHvtEkK6PmVLRmNs41qQqVM3 X-Received: by 2002:a05:6102:510f:b0:325:a73c:12b9 with SMTP id bm15-20020a056102510f00b00325a73c12b9mr5544506vsb.78.1648506947362; Mon, 28 Mar 2022 15:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648506947; cv=none; d=google.com; s=arc-20160816; b=QbbBXCtIoSL4xf2Nx+PHRydYZJ4n7FWIWJTQgkb9xNWQaQOKuyNuxTUzz7XVSLfw4K SJc+aZAEga09UrfECunAzsJpMHLfS2wkRNGlRgkOb5sMiTfFXyD9Aw9iPHw/Ts7i4Thn s4uvXmV6XhHpk7WVemslm6YgNeygX3I48J/fF2oLD4rT3IUygWaXgT+NuWNIyz0Tcnto 26vZDjrNK6NWtABcI0k6xAQ6waLUzyvF/pBZL3J6Nl/K8irsOxA6CN68D5JmJQSNV6hI tOexYFfyM2ElAgFHwGj+NAiRI9okgd7bESFNnw6YYPWXstbw/Q77CwC93ObBrGmrcsYV Cx1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PVRdwLRjbdaCvrvFVMElpF1SE8OywHiiQwb+mQwE81s=; b=o9rw2scezKR7a0BM8OsgRf/7FbpMx/SeNFfr/6xaeo73BCR/0/v3fhs+EuuRB9c937 RsoWwscS3RVaLYrKm56KWBjU06Q4pc0pNpqlVUh9sWXf3koaXBr7HKdq8xAsur2M5LaT b/qZELZGgOf3ebY/ZoCqceGcMQfaBor28C0Grl73lcp0NLV9jA3tql/6gjil3iPpkFk9 BgN54xDgn8kGJoQgoUf9lYoCjQprmgBn6qxCq0Gw5TyVnnA3MKqudvxWiNTJVU1fMmOu 7iRvTxEZ6B2dQJzOxKLGzSRDoa5v9LAjftgDxVX5Exnc3k0haad37m+TP+UK5F0X9EDK 0opA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=qWapL4vK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x13-20020a67c08d000000b00324c5c3c01asi3252180vsi.604.2022.03.28.15.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:35:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=qWapL4vK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53CA51E5205; Mon, 28 Mar 2022 14:45:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346365AbiC1Usf (ORCPT + 99 others); Mon, 28 Mar 2022 16:48:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346495AbiC1UpQ (ORCPT ); Mon, 28 Mar 2022 16:45:16 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A5EA18F; Mon, 28 Mar 2022 13:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=PVRdwLRjbdaCvrvFVMElpF1SE8OywHiiQwb+mQwE81s=; b=qWapL4vKx4xwxmY09OrhllQm6L BU1dDFYxJsD5tKND/6b+wQ3Aym8PGQ5Bam6kelQ7+mzYRc3h4I696m1e2DXKbUt5hDDrRTHVH39++ y5VXmy60nj4chA4+9DQtcph/1RD8vEXdSAjOfeBciXG+CW7MGeyBeXJlUq7BZljC3EZk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1nYwCs-00D4Cm-4L; Mon, 28 Mar 2022 22:43:18 +0200 Date: Mon, 28 Mar 2022 22:43:18 +0200 From: Andrew Lunn To: Michael Walle Cc: Horatiu Vultur , "David S . Miller" , Jakub Kicinski , Paolo Abeni , UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net] net: lan966x: fix kernel oops on ioctl when I/F is down Message-ID: References: <1ee5aec079e3eefff8475017ff1044bf@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ee5aec079e3eefff8475017ff1044bf@walle.cc> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 > > So rather than testing of running, it would be better to test if the > > phydev is NULL or not. > > What about the following: > > static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr, > int cmd) > { > struct lan966x_port *port = netdev_priv(dev); > > if (!phy_has_hwtstamp(dev->phydev) && port->lan966x->ptp) { > switch (cmd) { > case SIOCSHWTSTAMP: > return lan966x_ptp_hwtstamp_set(port, ifr); > case SIOCGHWTSTAMP: > return lan966x_ptp_hwtstamp_get(port, ifr); > } > } > > if (!dev->phydev) > return -ENODEV; > > return phy_mii_ioctl(dev->phydev, ifr, cmd); Yes, that is good. Andrew