🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #1115

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

#1115
From: Nicolai Buchwitz
Date: Fri, 09 Oct 2026 08:28
57 lines
8003 bytes
On 9.10.2026 03:27, Andrew Lunn wrote:
> 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

8a7ffeb795f8 dropped the final return -EINVAL when it converted the
returns to ret = ..., braces wouldn't have caught that. Fine with
adding them for a v2 though.

In either case:

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Tested-by: Nicolai Buchwitz <nb@tipi-net.de> # Raspberry Pi 3B+ 
(LAN7515)

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

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-343514-linux-kernel-netdev=dewy.ru
From: nb@tipi-net.de (Nicolai Buchwitz)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: usb: lan78xx: reject invalid EEPROM write
 requests
Date: Fri, 09 Oct 2026 10:28:31 +0200
Organization: Usenet Network
Message-ID: <4fbcbf4e3caf264ee5abef2275e02cfb@tipi-net.de>
References: <20261009005702.164936-1-stefanomunari.sm@gmail.com>
 <cc1a471e-ba76-4fe5-a982-0cbe1775c915@lunn.ch>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1063363"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IQLPh66MgFBQho6EhxkyfV7sp4A= sha256:ILl/zDCEfaxMbyQXztX3bmhthbcE3tMHZiU+ubE7bu4=
	sha1:kpCiqTRWjBCWqgENfvPFaAo4YLw= sha256:Y+bJClIVDvu6iQSlQrc/u3OGo1ncJ24Zy7G9pHe+ho8=
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 599F710F609; Fri,  9 Oct 2026 11:29:00 +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 (2048-bit key)
	header.d=tipi-net.de
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 zkUHKOMNOE_T;
	Fri,  9 Oct 2026 11:28:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-343514-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 6228810F607; Fri,  9 Oct 2026 11:28:50 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sin.lore.kernel.org (Postfix) with ESMTP id 0B8CE24460; Fri,  9 Oct 2026 08:28:48 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CEB03C4557;
	Fri,  9 Oct 2026 08:28:47 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b="GU8rHtvz"
X-Received: from mail.tipi-net.de (mail.tipi-net.de [194.13.80.246])
	(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 C5FCD3101D0;
	Fri,  9 Oct 2026 08:28:42 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.13.80.246
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1791534527; cv=none; b=vBsXqJw5Fn8gjzmu2QHHM/UE8t829aWXdjeq+9vcTBESCnC+zh7cnVp/OHd80nrC6iU2gIWL1Hg8oF99vKQyoe8mem5Q6ncO0nlYje91HldpT6gJ2LruF9fGmYoAitsR08R62aBgxaBztH5PscGsSUuJ0D98vGZmsuOSEmm4s34=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1791534527; c=relaxed/simple;
	bh=ZGMjphjVRG+EqkKY2GbeiSMoAegjQTgc+qG7pej+Yds=;
	h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References:
	 Message-ID:Content-Type; b=ahl9u3nxId/M6AMTzB9dMa55ZBash1WsvBMJJACrr2oqZelcIVx+cJCYwD7g4Xl5+3VMIgGXxRn1vp7NqwT2CUNaItHB92zp5857iDwIuyDKlEklryG5KrlN7ezGw9Sz5nIzSnZOiqfv8mTvKwnNNU3be0WXJnQPb1LE69JdMJ4=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de; spf=pass smtp.mailfrom=tipi-net.de; dkim=pass (2048-bit key) header.d=tipi-net.de header.i=@tipi-net.de header.b=GU8rHtvz; arc=none smtp.client-ip=194.13.80.246
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tipi-net.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tipi-net.de
X-Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3FFEEA1551;
	Fri,  9 Oct 2026 10:28:31 +0200 (CEST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tipi-net.de; s=dkim;
	t=1791534513; h=from:subject:date:message-id:to:cc:mime-version:content-type:
	 content-transfer-encoding:in-reply-to:references;
	bh=HQbvHG9dS6Fz273yiv0iGKMQDZdhvY99dKZijkTdQdE=;
	b=GU8rHtvzBPZb+mxT4QKfqAHxlxmrtxZDw4fH6wYEN7QpgALC9hLkjtigEDwUvDHkXmaPhE
	FbiIXwS3Lm2oweabliX9wL7h0R0OiSAPRt5smELMkp69bpGjGS4qErVswRkTEaFdPJt3sP
	JTJwORh9PlwEDyHM2B6MHxZkHKuxr37cZeXng9lHBN360ZwUju7Tcko0dLcy1XB27uUTAg
	CvSyAcXFwmcRj6hc3EEoSyX/DLa1plxz2axwVV7boU8hoqKoED6Ovar/+n7lXW8sVsWrE+
	8JP0Sg0fE0nDTaPL6FuJxcN1T3HAg2dg1DuIK2KxSwn3Jc4f25t9pg7HVmDkXA==
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-Cc: Stefano Munari <stefanomunari.sm@gmail.com>, 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-In-Reply-To: <cc1a471e-ba76-4fe5-a982-0cbe1775c915@lunn.ch>
X-Sender: nb@tipi-net.de
X-Last-TLS-Session-Version: TLSv1.3