Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2827680pxb; Mon, 1 Nov 2021 02:39:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmZHTMxiXnt431oi3t+V1c9xBLdNpHtzxJNB5IVRjUjicXes4Lg6tLSTbeZRRIw4YXs50w X-Received: by 2002:a50:ab44:: with SMTP id t4mr30090848edc.105.1635759584415; Mon, 01 Nov 2021 02:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635759584; cv=none; d=google.com; s=arc-20160816; b=NJ1l0c/FF/8JaiyuUITtO5OAfKotXtZR/JOy9hUTQBEW6bUOpkZPsZoTdwH/fG5Npu It9h2BkEdI0/v++wZRix+HHJnQGHMAJ4TLg0jHvSVCIhCaD0OZGyO2CfwFaEJCcIjcsw 2K+KB9iUCbhz6zuIHigFitu/+M9Zrcr0briE6KpCiUCtD65I3/8huPUIot/xHIjh9AS3 tqpjH5j//2/ckoDz3fsItZwQOUhunIqWekzc1rZl9DtB2FLlElzlaxWMa77L1aJNndaN Zh4OA8OJYGh/EzfkaTYlqCsjWR+jQGenG0g1ILlkqv4U8i7V2fhXfitRgwK3mMLWaB6h Rj4Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gkg5oxUINf38NLVNWNQX7jfVAZlWsu7tdy+tL3BceCU=; b=EpkLjpBOqcnXA8UD9VicRXbQKWf5Vheb4xTlS9bCVoJheQfuaUZsXQz58ftB/6/h5L RyKsMst5QcdKz8B7Ee2e1ueL+MX6B6rT5mMhnrL/Ci9mbkYq4HZptg38Rk2krAKOqk2a Dym+CPLHcqB7XlbJWYO5WCHufLidqz87FtK3BWIC1beFPcGlzDZV7/yn8LgsqRA4rdid ZRZvCtFmvgoa2uo1KWYNO840Ak5XwfJZ8iXtKdcb6+Fklz3kZZ7KxVyhfuiEKl5P2BCP NYOSt8v+k2TjzsragJpB1PKKWU5AHDWyIMqQqdbGcDkxi6nfmz1fE9pkoFM0NLewV1uL s3WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kjghneod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz9si26265103edb.318.2021.11.01.02.39.20; Mon, 01 Nov 2021 02:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kjghneod; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233026AbhKAJkH (ORCPT + 99 others); Mon, 1 Nov 2021 05:40:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232236AbhKAJhp (ORCPT ); Mon, 1 Nov 2021 05:37:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E610861355; Mon, 1 Nov 2021 09:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1635758793; bh=0ieW+fV6l2QpNpy+89oS+MUGfuk6JQOELQCaNI6S3C0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kjghneodGqM5j7TVquKtFmpOyqrm8WuJ9JF3bWO5TJXp/iqrqED3NAxMqulJBfD8F 4gvq+OOUyC6oNGFP1iIKD5nllDN6HwGQUnFxe87ziuSYmVtDwS/Q7m1ONwNJKF2/UT oNfkwfPHGIt4djOYfXj5ilY465djpo0wEL0BJFG4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , "David S. Miller" Subject: [PATCH 5.10 61/77] phy: phy_ethtool_ksettings_get: Lock the phy for consistency Date: Mon, 1 Nov 2021 10:17:49 +0100 Message-Id: <20211101082524.459421206@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211101082511.254155853@linuxfoundation.org> References: <20211101082511.254155853@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn commit c10a485c3de5ccbf1fff65a382cebcb2730c6b06 upstream. The PHY structure should be locked while copying information out if it, otherwise there is no guarantee of self consistency. Without the lock the PHY state machine could be updating the structure. Fixes: 2d55173e71b0 ("phy: add generic function to support ksetting support") Signed-off-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -316,6 +316,7 @@ EXPORT_SYMBOL(phy_ethtool_ksettings_set) void phy_ethtool_ksettings_get(struct phy_device *phydev, struct ethtool_link_ksettings *cmd) { + mutex_lock(&phydev->lock); linkmode_copy(cmd->link_modes.supported, phydev->supported); linkmode_copy(cmd->link_modes.advertising, phydev->advertising); linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising); @@ -334,6 +335,7 @@ void phy_ethtool_ksettings_get(struct ph cmd->base.autoneg = phydev->autoneg; cmd->base.eth_tp_mdix_ctrl = phydev->mdix_ctrl; cmd->base.eth_tp_mdix = phydev->mdix; + mutex_unlock(&phydev->lock); } EXPORT_SYMBOL(phy_ethtool_ksettings_get);