* [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe()
@ 2023-10-09 12:49 Ma Ke
2023-10-09 14:22 ` Niklas Cassel
2023-10-09 22:33 ` Damien Le Moal
0 siblings, 2 replies; 4+ messages in thread
From: Ma Ke @ 2023-10-09 12:49 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, linux-kernel, Ma Ke
In mv_platform_probe(), check the return value of clk_prepare_enable()
and return the error code if clk_prepare_enable() returns an
unexpected value.
Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
drivers/ata/sata_mv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 45e48d653c60..df3a02e7a50b 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4125,8 +4125,10 @@ static int mv_platform_probe(struct platform_device *pdev)
hpriv->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(hpriv->clk))
dev_notice(&pdev->dev, "cannot get optional clkdev\n");
- else
- clk_prepare_enable(hpriv->clk);
+ else {
+ rc = clk_prepare_enable(hpriv->clk);
+ goto err;
+ }
for (port = 0; port < n_ports; port++) {
char port_number[16];
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe()
2023-10-09 12:49 [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe() Ma Ke
@ 2023-10-09 14:22 ` Niklas Cassel
2023-10-09 22:33 ` Damien Le Moal
1 sibling, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2023-10-09 14:22 UTC (permalink / raw)
To: Ma Ke
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org
On Mon, Oct 09, 2023 at 08:49:55PM +0800, Ma Ke wrote:
> In mv_platform_probe(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
>
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
> drivers/ata/sata_mv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 45e48d653c60..df3a02e7a50b 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4125,8 +4125,10 @@ static int mv_platform_probe(struct platform_device *pdev)
> hpriv->clk = clk_get(&pdev->dev, NULL);
> if (IS_ERR(hpriv->clk))
> dev_notice(&pdev->dev, "cannot get optional clkdev\n");
> - else
> - clk_prepare_enable(hpriv->clk);
> + else {
> + rc = clk_prepare_enable(hpriv->clk);
> + goto err;
> + }
>
> for (port = 0; port < n_ports; port++) {
> char port_number[16];
> --
> 2.37.2
>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe()
2023-10-09 12:49 [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe() Ma Ke
2023-10-09 14:22 ` Niklas Cassel
@ 2023-10-09 22:33 ` Damien Le Moal
2023-10-10 9:06 ` Niklas Cassel
1 sibling, 1 reply; 4+ messages in thread
From: Damien Le Moal @ 2023-10-09 22:33 UTC (permalink / raw)
To: Ma Ke; +Cc: linux-ide, linux-kernel
On 10/9/23 21:49, Ma Ke wrote:
> In mv_platform_probe(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
>
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
> drivers/ata/sata_mv.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 45e48d653c60..df3a02e7a50b 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4125,8 +4125,10 @@ static int mv_platform_probe(struct platform_device *pdev)
> hpriv->clk = clk_get(&pdev->dev, NULL);
> if (IS_ERR(hpriv->clk))
> dev_notice(&pdev->dev, "cannot get optional clkdev\n");
> - else
> - clk_prepare_enable(hpriv->clk);
> + else {
> + rc = clk_prepare_enable(hpriv->clk);
> + goto err;
This is wrong. The goto err should only be done if there is an error.
Did you even test your own patch ???
> + }
>
> for (port = 0; port < n_ports; port++) {
> char port_number[16];
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe()
2023-10-09 22:33 ` Damien Le Moal
@ 2023-10-10 9:06 ` Niklas Cassel
0 siblings, 0 replies; 4+ messages in thread
From: Niklas Cassel @ 2023-10-10 9:06 UTC (permalink / raw)
To: Damien Le Moal
Cc: Ma Ke, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
On Tue, Oct 10, 2023 at 07:33:49AM +0900, Damien Le Moal wrote:
> On 10/9/23 21:49, Ma Ke wrote:
> > In mv_platform_probe(), check the return value of clk_prepare_enable()
> > and return the error code if clk_prepare_enable() returns an
> > unexpected value.
> >
> > Signed-off-by: Ma Ke <make_ruc2021@163.com>
> > ---
> > drivers/ata/sata_mv.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> > index 45e48d653c60..df3a02e7a50b 100644
> > --- a/drivers/ata/sata_mv.c
> > +++ b/drivers/ata/sata_mv.c
> > @@ -4125,8 +4125,10 @@ static int mv_platform_probe(struct platform_device *pdev)
> > hpriv->clk = clk_get(&pdev->dev, NULL);
> > if (IS_ERR(hpriv->clk))
> > dev_notice(&pdev->dev, "cannot get optional clkdev\n");
> > - else
> > - clk_prepare_enable(hpriv->clk);
> > + else {
> > + rc = clk_prepare_enable(hpriv->clk);
> > + goto err;
>
> This is wrong. The goto err should only be done if there is an error.
> Did you even test your own patch ???
The "if (rc)" was there in V1....
I should have caught this in my review of V2.
BTW, if we want to be compliant with the coding kernel standard,
you should also have braces on the if (IS_ERR()),
since there are braces on the else-clause.
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-10 9:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-09 12:49 [PATCH v2] ata: sata_mv: aspeed: fix value check in mv_platform_probe() Ma Ke
2023-10-09 14:22 ` Niklas Cassel
2023-10-09 22:33 ` Damien Le Moal
2023-10-10 9:06 ` Niklas Cassel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox