Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp5530370lfu; Mon, 28 Mar 2022 16:04:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0CCpbY2lynPn3xIdoH98Dt1q1Jn6qigBQon+GBK58AaZS8NFuV59uRzv2lGVus+L2wal9 X-Received: by 2002:a37:a54b:0:b0:67b:4cb7:4645 with SMTP id o72-20020a37a54b000000b0067b4cb74645mr17842010qke.132.1648508691909; Mon, 28 Mar 2022 16:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648508691; cv=none; d=google.com; s=arc-20160816; b=axdgJzXq84o3FnuGGN9blBF6r0/lMbjmpfIOhi1ulyWIMWoJcjW76AbGLdZut2ubfQ MquXfI/ZE74ZLWtciUNDpSulX/bHVnbWRlhY57yNZXTHoBnEKJWykaKe5KAmD7lm5TKX alzfkj2TzONx/qXG1lUQH82ecxP7tTpbSpcoRU133ICEQ5UZBImyTdi88jOW+zka3E66 NOjK2n9J7lc5UsdgkaxBf/tuxVw5bgY/FmTwS3eOw3piAMF9+554SCAGBMOXGPatrYSb 3AeGx53G+fFNWUSRF9TIVy71hs5QAnlIDDq/CpQjdKaw5IQUo2yaTfNFmdcUZKLi/CGx edkA== 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=vp4rKL6VyEnIJD26VD7lbiGVoFzegzSinsmaY3pZqhA=; b=iTTU/o/70DfBrp76ZIHnpzRh8Cr8Znxx/IrrjFG6VXQh8dTdR3qeQPvgg5Kd2H+0cJ JM2TVrJ4Q/JZWGMEh/xPLcVfWP8ew7/+6rMh/XRDJmnLf1F5y8GlVqm0VGjf9ovr1ZNi DFXpD+9mzcFHJeKDAN7vCbnZBS2si8oAsCuNgmog6UgUQFdxkkI60G0yJqaxVHXZmTNc SLIyQZDb8uJMPMBYYuXfcjXV0oOdspYxapM8D8uOTKpsonj+2xcNfBF+y097UGgFNF9+ bvL2o/7FW1QGvntnLKAooemM8CmS8zICGhevRiWZCyWYZMqbKXwddnEtfNLyS02aLtVn 0QHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=k7mL78gO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h1-20020a056102214100b0032537906a4asi2758385vsg.777.2022.03.28.16.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 16:04:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=k7mL78gO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 C100B81677; Mon, 28 Mar 2022 15:12:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229612AbiC1WOP (ORCPT + 99 others); Mon, 28 Mar 2022 18:14:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiC1WN7 (ORCPT ); Mon, 28 Mar 2022 18:13:59 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D59F14A927; Mon, 28 Mar 2022 15:04: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 05FF92223A; Tue, 29 Mar 2022 00:03:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648505038; 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=vp4rKL6VyEnIJD26VD7lbiGVoFzegzSinsmaY3pZqhA=; b=k7mL78gO3w6EI+zWoydALo8/RJZOCQoA1ekmvW4MD+7OaocvhfpIfwtxUronph9lqMq9Oe 09TLHEF8gFp3o6QxzhDrfnv1F/2bfVrJIjLDC5/22nGMXh4kRcyqxY524zjlsXukv0rqAy 1CTg2TFmshcNcHfPPSYsfRS89cAHMVA= 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 v2 net] net: lan966x: fix kernel oops on ioctl when I/F is down Date: Tue, 29 Mar 2022 00:03:50 +0200 Message-Id: <20220328220350.3118969-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=-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 ioctls handled by phy_mii_ioctl() will cause a kernel oops when the interface is down. Fix it by making sure there is a PHY attached. Fixes: 735fec995b21 ("net: lan966x: Implement SIOCSHWTSTAMP and SIOCGHWTSTAMP") Signed-off-by: Michael Walle --- changes since v1: - reword commit message - test for the presence of phydev instead of the interface state - move the test just before phy_mii_ioctl() 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..1759b0e2b56f 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -408,6 +408,9 @@ static int lan966x_port_ioctl(struct net_device *dev, struct ifreq *ifr, } } + if (!dev->phydev) + return -ENODEV; + return phy_mii_ioctl(dev->phydev, ifr, cmd); } -- 2.30.2