🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1005

Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write requests

#1005
From: Andrew Lunn
Date: Fri, 09 Oct 2026 01:27
41 lines
7371 bytes
On Fri, Oct 09, 2026 at 02:57:02AM +0200, Stefano Munari wrote:
> The runtime PM handling removed the -EINVAL return for invalid
> EEPROM/OTP write requests. These requests now return zero from a
> successful usb_autopm_get_interface() call, even though no data is
> written.
> 
> Set ret to -EINVAL for invalid requests while preserving the runtime
> PM reference release.
> 
> Fixes: 8a7ffeb795f8 ("lan78xx: Fix for eeprom read/write when device auto suspend")
> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
> ---
> Tested on a Raspberry Pi 3 Model B+ with the onboard Ethernet
> controller, using raspberrypi/linux commit bba53a117a4a on the
> rpi-6.6.y branch as the baseline.
> 
>   ethtool -E eth0 magic 0 offset 0 length 1 value 0
> 
> The command succeeds without the patch and reports "Invalid argument"
> with the patch applied.
> ---
>  drivers/net/usb/lan78xx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 5655941f1478..7ac263454d45 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -1719,6 +1719,8 @@ static int lan78xx_ethtool_set_eeprom(struct net_device *netdev,
>  		 (ee->len == 512) &&
>  		 (data[0] == OTP_INDICATOR_1))
>  		ret = lan78xx_write_raw_otp(dev, ee->offset, ee->len, data);
> +	else
> +		ret = -EINVAL;

It might be the nested if's without {} which caused the broken patch?

Maybe add some brackets to make it clearer?

      Andrew
Technical Details
Message-ID: <cc1a471e-ba76-4fe5-a982-0cbe1775c915@lunn.ch>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343382-linux-kernel-netdev=dewy.ru
References: <20261009005702.164936-1-stefanomunari.sm@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-343382-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write
 requests
Date: Fri, 9 Oct 2026 03:27:25 +0200
Organization: Usenet Network
Message-ID: <cc1a471e-ba76-4fe5-a982-0cbe1775c915@lunn.ch>
References: <20261009005702.164936-1-stefanomunari.sm@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1010525"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:xxDXiY9bqD2lyuO4mVnR7cu/igI= sha256:N/oySca6JOYqANJU9ef6VagfUKjcEr6POgv3XLnJD14=
	sha1:DI4qrqCXAPXnx8vZ32RJrUSG774= sha256:ryJmO1iADtNiQEMGoIsMDi8VXo1MczLmtPNttB6t+X4=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id A393B10F2A3; Fri,  9 Oct 2026 04:27:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.75
X-Spam-Status: No, score=-0.75 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=lunn.ch
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id p5W25fbAQ_4i;
	Fri,  9 Oct 2026 04:27:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-343382-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 2534310E9C2; Fri,  9 Oct 2026 04:27:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sea.lore.kernel.org (Postfix) with ESMTP id 1DB053E7E6; Fri,  9 Oct 2026 01:27:38 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CC8230AAA6;
	Fri,  9 Oct 2026 01:27:37 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="2wnHQepP"
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 511B018859B;
	Fri,  9 Oct 2026 01:27:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791509257; cv=none; b=okO7HnYHTmigHjrYUqy7PnoinNLTjXE+hPW/Y8y4ueybnTiORFom1SKBN/omXh2k/y/f9XqG4UrUqMkYjAaHb2vemlX7uNi6gd5vFkEU3C1UdsX6Il03giWSFSZBw2Eprx5g58GIz9TMOyEDmYMOEgjnhNJn0DpmZFQlF7z5Rvo=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791509257; c=relaxed/simple;
	bh=Ti0gNoT+2F5zJ+Z0iIoiDmVEGOryiPokJE5D/Lslj+k=;
	h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To; b=GSI80RNP1JD2ahls6VfaiigQ8PVh2q+xUMRcvpVYJjZa2l/UIaXVHuGdclvAlK1aRMm93/1lwHlqJCwVs8XF7Vi+qyreO2/ZCPxRUfWu2cCPidrF/Cew9j6lwWkOUlR+K1Hn1+ixF4xsPNRisSgdUg8+KEgVRSrxBC4Lz2bKz2c=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=2wnHQepP; arc=none smtp.client-ip=156.67.10.101
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-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=dw5ebkUEZYN/o691XouQG0ZrARfZ7nxdbZY4Hy1N37s=; b=2wnHQepPcGO6w6SQ8aqQ9bGqiY
	zK4oXVjMWb9GcYDRM3uwe66TL4hJ5luErk5y7sDxi/MDH+2Lu710AWgwqNHnPUnDkrdI0655Ujxqq
	RDiAS6LJdQPYOHwRKdhJY0pi2u6VWknT3ipg7ZlGdzmQOOIM8vGG88IqUO2iLThuz/88=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xEzOP-009iDt-Tj; Fri, 09 Oct 2026 03:27:25 +0200
X-Cc: netdev@vger.kernel.org,
	Thangaraj Samynathan <Thangaraj.S@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Nisar Sayed <Nisar.Sayed@microchip.com>, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-In-Reply-To: <20261009005702.164936-1-stefanomunari.sm@gmail.com>