Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp558598imp; Thu, 21 Feb 2019 06:50:34 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib/IZIO6ccQ0W7/T1FJXmjwHxpuWhSjCZck0F54GRsLcGy9Di3lIEaVSu6ebzAoSFhqmeXV X-Received: by 2002:a17:902:7889:: with SMTP id q9mr22578669pll.305.1550760634233; Thu, 21 Feb 2019 06:50:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550760634; cv=none; d=google.com; s=arc-20160816; b=lWafJrJr0Qh8HdHLSA1N3U8wp9XVEqPpTW9sWAmFMXXQwQQm8MgQa5T+HEBj+7IN5T 7tZL+Q+FPNi59ipCxOxddRsyXUAl8d1aQtcSxzazm6lzLKtBELUVZaYks6OxM0SzZa7K MgFI+ne/YDX74TMUy3oAKjXZL6LR1hbaWEuQrmzhC03fsRSkJC9Jd9QhU2iSVmCp973H oXofOjRFG98KcDlTeNu3nmHd0yCh46ia+nv7KZF4wHMt9trmEX2Bu6AgDqfkwyfABYOY fJYldxONg58AtQ8Z8VT/jts64fwGNfUisFfH68p1JCAPWUw0BYtZylneM5q1/myNqfQL IQHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QvPuQwlp+gYK1LeiVOjYcyGLufaMui6Hrh1I+AnzYjw=; b=d7dOPmqYp0JGkGXdeSKaVR4WWSbhb2dp/EVkOzQepJNcWjErLMvfW42vXCXanmo/6e 0OID4fSkC5pEF5uRynD9Dkx4eNDJILDCXUGmkSJf2DECKnTbSyeSTFGMUscAQAkNGfcQ tW4nTAKWfX41G+A2fs9ac1VkylpDWiczIqInM4L1FNU9Fs/7NbCh7iRPwzed9h73IpVZ aSQyuvmyPgjDP8x92BzhdYtdedPrxTOM73Nuj/+M+BtavQpecIlDAt/2SSZUtqHXqXNM 9NcGJWgboavdArtcbTJyZag5l1aOX84G9dEQ0sZxlR7NPGygLGTjkz7YGjPPlqn133Zm Fh1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YQxtBiKC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si22630424pld.436.2019.02.21.06.50.18; Thu, 21 Feb 2019 06:50:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YQxtBiKC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728911AbfBUOj3 (ORCPT + 99 others); Thu, 21 Feb 2019 09:39:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:33398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbfBUOj1 (ORCPT ); Thu, 21 Feb 2019 09:39:27 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F71B2084D; Thu, 21 Feb 2019 14:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550759966; bh=mVY0S8RndXss8zGbQF2NL1OnnAUqviLioeOx1ByVShw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YQxtBiKCyLWXYR8QVluV/Tz0u7+dFNAifnd4f2zbgR/sdWunVVxSEFKkAYwV+STjR A1INsLT+Y2HVG/tN/L0fDdqLzGGjR6SG2bPRFJy/M+4eGcpOwuUHMhcC62qkKPe7ir X9zrTvOSf0hP5VDh/hSji04voTPvDqS2kEW4u+ys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jose Abreu , Joao Pinto , "David S. Miller" , Giuseppe Cavallaro , Alexandre Torgue Subject: [PATCH 4.9 15/20] net: stmmac: Fix a race in EEE enable callback Date: Thu, 21 Feb 2019 15:35:53 +0100 Message-Id: <20190221125243.868841425@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221125242.153179182@linuxfoundation.org> References: <20190221125242.153179182@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jose Abreu [ Upstream commit 8a7493e58ad688eb23b81e45461c5d314f4402f1 ] We are saving the status of EEE even before we try to enable it. This leads to a race with XMIT function that tries to arm EEE timer before we set it up. Fix this by only saving the EEE parameters after all operations are performed with success. Signed-off-by: Jose Abreu Fixes: d765955d2ae0 ("stmmac: add the Energy Efficient Ethernet support") Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -676,25 +676,27 @@ static int stmmac_ethtool_op_set_eee(str struct ethtool_eee *edata) { struct stmmac_priv *priv = netdev_priv(dev); + int ret; - priv->eee_enabled = edata->eee_enabled; - - if (!priv->eee_enabled) + if (!edata->eee_enabled) { stmmac_disable_eee_mode(priv); - else { + } else { /* We are asking for enabling the EEE but it is safe * to verify all by invoking the eee_init function. * In case of failure it will return an error. */ - priv->eee_enabled = stmmac_eee_init(priv); - if (!priv->eee_enabled) + edata->eee_enabled = stmmac_eee_init(priv); + if (!edata->eee_enabled) return -EOPNOTSUPP; - - /* Do not change tx_lpi_timer in case of failure */ - priv->tx_lpi_timer = edata->tx_lpi_timer; } - return phy_ethtool_set_eee(priv->phydev, edata); + ret = phy_ethtool_set_eee(dev->phydev, edata); + if (ret) + return ret; + + priv->eee_enabled = edata->eee_enabled; + priv->tx_lpi_timer = edata->tx_lpi_timer; + return 0; } static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)