From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.amicon.ru (unknown [77.108.111.100]) (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 6F3B33E5ED9; Wed, 25 Mar 2026 16:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.108.111.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774454587; cv=none; b=gSh81oVeXZD016hORf062E7uRJjJCKEoQA0wXzTy6/BKPq5FFdDbpm7Kwsh4yidTs8lhSIKpCxB3kNBfKYXMHN1MEX4dJ6/esyktiKiwvo1kpHfwLESKTA7I40WLEpSsGZDt2FLliS3zbdDPWc5Tx0aJJqTtMV/XtwtQV9XG9YI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774454587; c=relaxed/simple; bh=03sGA4YSqaJAWjqStwtwmW5eSsQBADrXP8DO+DVWTos=; h=Content-Type:From:To:CC:Subject:Date:Message-ID:In-Reply-To: References:MIME-Version; b=SAnXL5JENFSyoBqVifhnBZLCjas6obFobgWbycuu47IUGw/zvmo/9sXe3GY3A//izpPrJu9TN68/vpWgqnqdEwNgcx+fvU9FA4SCw7/rZC4uO8xqFEqFa2/nuz/ggXkK/lw00QcG4thwOpgWahKBdgyAYmefyQWLN2asxfGOEvk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amicon.ru; spf=pass smtp.mailfrom=amicon.ru; dkim=pass (2048-bit key) header.d=amicon.ru header.i=@amicon.ru header.b=CRqFM5VI; arc=none smtp.client-ip=77.108.111.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amicon.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amicon.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amicon.ru header.i=@amicon.ru header.b="CRqFM5VI" Content-Transfer-Encoding: 8bit Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; d=amicon.ru; s=mail; c=simple/simple; t=1774454583; h=from:subject:to:date:message-id; bh=03sGA4YSqaJAWjqStwtwmW5eSsQBADrXP8DO+DVWTos=; b=CRqFM5VIiOq0iJUi83p4CGxLQlUp81t+J0Xgftt5yuMOqE0stZrLI3xLTyzvWZcHjw8UUK0+zgB Ejfk5n6ViRmWUdnbZy6lXejYT78QZzYWvsqPk6/BhnnR9KexbIEgwGlwJ7/rNMkLyVmp3wM6Q8sGh y3ziU5dk468JPnf1rqLgjz/s8Y3VoqlzKvMtzJtA7et497DzG1tGbaOf9X82oRiDmFn7kc7/pR3IJ kut5LGM+DIi45Gy1au/cJoH/WNE++Z4vjKhCRRghD57sSX8w+HJmWmC4zY44lXE1dn1s5s9SstBSV 8L1+8XBvlNqeJPuIpV/bwSoA6ZkLFHxyOTQQ== Received: from example.com (172.16.2.46) by mail.amicon.lan (192.168.0.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.27; Wed, 25 Mar 2026 19:03:03 +0300 From: Agalakov Daniil To: Tony Nguyen CC: Agalakov Daniil , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni , , , , , "Daniil Iskhakov" , Roman Razov Subject: [PATCH net v3] e1000: check return value of e1000_read_eeprom Date: Wed, 25 Mar 2026 19:00:07 +0300 Message-ID: <20260325160231.1431929-1-ade@amicon.ru> X-Mailer: git-send-email 2.51.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: mail.amicon.lan (192.168.0.59) To mail.amicon.lan (192.168.0.59) [Why] e1000_set_eeprom() performs a read-modify-write operation when the write range is not word-aligned. This requires reading the first and last words of the range from the EEPROM to preserve the unmodified bytes. However, the code does not check the return value of e1000_read_eeprom(). If the read fails, the operation continues using uninitialized data from eeprom_buff. This results in corrupted data being written back to the EEPROM for the boundary words. Add the missing error checks and abort the operation if reading fails. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Co-developed-by: Iskhakov Daniil Signed-off-by: Iskhakov Daniil Signed-off-by: Agalakov Daniil --- v3: - Remove extra blank line. v2: - Split from original series. - Updated the error checking logic to be consistent with the implementation in the e1000e driver. drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 4 ++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index ab232b3fbbd0..3c3c6de95af7 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c @@ -506,6 +506,9 @@ static int e1000_set_eeprom(struct net_device *netdev, &eeprom_buff[last_word - first_word]); } + if (ret_val) + goto out; + /* Device's eeprom is always little-endian, word addressable */ for (i = 0; i < last_word - first_word + 1; i++) le16_to_cpus(&eeprom_buff[i]); @@ -522,6 +525,7 @@ static int e1000_set_eeprom(struct net_device *netdev, if ((ret_val == 0) && (first_word <= EEPROM_CHECKSUM_REG)) e1000_update_eeprom_checksum(hw); +out: kfree(eeprom_buff); return ret_val; } -- 2.51.0