drivers/ata/libata-core: check return value of sata_scr_read()
PATCH 1/1 drivers/ata/libata-core: check return value of sata_scr_read()
sata_scr_read() could return 0 on failure. Check the return value.
--- drivers/ata/libata-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/ata/libata-core.c +2 -1
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 1 line · Li Zhong
sata_scr_read()could return 0 on failure. Check the return value.
Looks OK as a fix but the above sentence has a bug. 0 indicates success, not failure. So this should read:
sata_scr_read() may fail with a negative error code. Check that function return value when reading the control register.
Also, the patch title should be something like:
ata: libata-core: Check errors in sata_print_link_status()
Quoted 20 lines
Signed-off-by Li Zhong <[email protected]>--- drivers/ata/libata-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/ata/libata-core.c +2
-1@@ -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 ;
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 7 lines · Damien Le Moal
Quoted 1 line · Li Zhong
sata_scr_read()could return 0 on failure. Check the return value.Looks OK as a fix but the above sentence has a bug. 0 indicates success, not failure. So this should read:
Quoted 7 lines
sata_scr_read()may fail with a negative error code. Check that function return value when reading the control register.Also, the patch title should be something like:
ata: libata-core: Check errors in
sata_print_link_status()
Thanks. Will fix it in the new version.
Quoted 25 lines
Quoted 11 lines
Signed-off-by Li Zhong <[email protected]>--- drivers/ata/libata-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/ata/libata-core.c +0
-0drivers/ata/libata-core.c static void sata_print_link_status(struct ata_link *link) · line 3028
Quoted 9 lines
drivers/ata/libata-core.c +2
-1@@ -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 ;--
Damien Le Moal
Western Digital Research