]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
samples: rust: fix endianness issue in rust_driver_pci
authorMarko Turk <mt@markoturk.info>
Wed, 10 Dec 2025 11:25:51 +0000 (12:25 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Wed, 17 Dec 2025 17:10:58 +0000 (18:10 +0100)
MMIO backend of PCI Bar always assumes little-endian devices and
will convert to CPU endianness automatically. Remove the u32::from_le
conversion which would cause a bug on big-endian machines.

Cc: stable@vger.kernel.org
Reviewed-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Marko Turk <mt@markoturk.info>
Fixes: 685376d18e9a ("samples: rust: add Rust PCI sample driver")
Link: https://patch.msgid.link/20251210112503.62925-2-mt@markoturk.info
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
samples/rust/rust_driver_pci.rs

index 5823787bea8ec3e9a38ab3e4941f6c88d70e00b4..fa677991a5c450d849c93b68c836df023f38cbc5 100644 (file)
@@ -48,7 +48,7 @@ impl SampleDriver {
         // Select the test.
         bar.write8(index.0, Regs::TEST);
 
-        let offset = u32::from_le(bar.read32(Regs::OFFSET)) as usize;
+        let offset = bar.read32(Regs::OFFSET) as usize;
         let data = bar.read8(Regs::DATA);
 
         // Write `data` to `offset` to increase `count` by one.