[PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read()

From: Li Zhong
Date: Sun Aug 28 2022 - 16:45:06 EST


sata_scr_read() could return 0 on failure. Check the return value.

Signed-off-by: Li Zhong <floridsleeves@xxxxxxxxx>
---
drivers/ata/libata-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 826d41f341e4..ae08c7d35cb0 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3021,7 +3021,8 @@ static void sata_print_link_status(struct ata_link *link)

if (sata_scr_read(link, SCR_STATUS, &sstatus))
return;
- sata_scr_read(link, SCR_CONTROL, &scontrol);
+ if (sata_scr_read(link, SCR_CONTROL, &scontrol))
+ return;

if (ata_phys_link_online(link)) {
tmp = (sstatus >> 4) & 0xf;
--
2.25.1