linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read()
@ 2022-08-28 20:44 Li Zhong
  2022-08-30  1:38 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhong @ 2022-08-28 20:44 UTC (permalink / raw)
  To: linux-kernel, linux-ide; +Cc: damien.lemoal, Li Zhong

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

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read()
  2022-08-28 20:44 [PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read() Li Zhong
@ 2022-08-30  1:38 ` Damien Le Moal
  2022-09-03 23:05   ` Li Zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2022-08-30  1:38 UTC (permalink / raw)
  To: Li Zhong, linux-kernel, linux-ide; +Cc: damien.lemoal

On 2022/08/29 5:45, Li Zhong wrote:
> 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()

> 
> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  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;

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read()
  2022-08-30  1:38 ` Damien Le Moal
@ 2022-09-03 23:05   ` Li Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zhong @ 2022-09-03 23:05 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-kernel, linux-ide, damien.lemoal

On Mon, Aug 29, 2022 at 6:38 PM Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
>
> On 2022/08/29 5:45, Li Zhong wrote:
> > 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()
>

Thanks. Will fix it in the new version.

> >
> > Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> > ---
> >  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;
>
> --
> Damien Le Moal
> Western Digital Research
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-03 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-28 20:44 [PATCH v1] drivers/ata/libata-core: check return value of sata_scr_read() Li Zhong
2022-08-30  1:38 ` Damien Le Moal
2022-09-03 23:05   ` Li Zhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).