30 lines
1.0 KiB
Diff
30 lines
1.0 KiB
Diff
|
|
From 048b51010d25187799632082917b8b883df98df7 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jiajie Li <lijiajie11@huawei.com>
|
||
|
|
Date: Thu, 17 Feb 2022 18:11:07 +0800
|
||
|
|
Subject: [PATCH 2/5] legacy/fwcfg: fix bug of wrong size judgment
|
||
|
|
|
||
|
|
When call `read_data_reg`, the size should be in (0,8], not (0,8).
|
||
|
|
Fix it.
|
||
|
|
|
||
|
|
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
|
||
|
|
---
|
||
|
|
devices/src/legacy/fwcfg.rs | 2 +-
|
||
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/devices/src/legacy/fwcfg.rs b/devices/src/legacy/fwcfg.rs
|
||
|
|
index 7e9e73f..866bab2 100644
|
||
|
|
--- a/devices/src/legacy/fwcfg.rs
|
||
|
|
+++ b/devices/src/legacy/fwcfg.rs
|
||
|
|
@@ -688,7 +688,7 @@ impl FwCfgCommon {
|
||
|
|
/// Return the value of the register
|
||
|
|
///
|
||
|
|
fn read_data_reg(&mut self, _addr: u64, mut size: u32) -> Result<u64> {
|
||
|
|
- if size == 0 || size >= std::mem::size_of::<u64>() as u32 {
|
||
|
|
+ if size == 0 || size > std::mem::size_of::<u64>() as u32 {
|
||
|
|
bail!(
|
||
|
|
"Failed to read from FWcfg data register, size {} overflows",
|
||
|
|
size
|
||
|
|
--
|
||
|
|
2.25.1
|
||
|
|
|