Skip to contentSkip to conversation

rts5208: fix a missing check of ms read

PATCH In review Kangjie Lu 2 participants 3 messages Dec 20, 2018 – Jan 2, 2019 Staging

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 rts5208: fix a missing check of ms read

When ms_read_extra_data fails, the data read in "extra" buffer is just incorrect and thus should be used. However, "extra" is used in multiple places no matter ms_read_extra_data() fails or not. The fix checks the status of ms_read_extra_data() and returns with an error code upon its failure.

---
 drivers/staging/rts5208/ms.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rts5208/ms.c +3 -1
index f53adf15c685..03b359ec69e6 100644
@@ -1676,7 +1676,9 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk,
 			return STATUS_FAIL;
 		}
 
-		ms_read_extra_data(chip, old_blk, i, extra, MS_EXTRA_SIZE);
+		retval = ms_read_extra_data(chip, old_blk, i, extra, MS_EXTRA_SIZE);
+		if (retval != STATUS_SUCCESS)
+			return STATUS_FAIL;
 
 		retval = ms_set_rw_reg_addr(chip, OverwriteFlag,
 					    MS_EXTRA_SIZE, SystemParm, 6);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Kangjie Lu
Quoted 7 lines · Kangjie Lu

When ms_read_extra_data fails, the data read in "extra" buffer is just incorrect and thus should be used. However, "extra" is used in multiple places no matter ms_read_extra_data() fails or not. The fix checks the status of ms_read_extra_data() and returns with an error code upon its failure.

Looks good.

regards,
dan carpenter