2021-09-29 06:43:31

by Yang Li

[permalink] [raw]
Subject: [PATCH -next] pcd: capture error codes on pcd_probe() and pf_probe()

No error code were being captured when pcd_probe() and
pf_probe() fail, capture them by assigning them to ret.

Clean up smatch warning:
drivers/block/paride/pcd.c:939 pcd_init_unit() warn: missing error code
'ret'
drivers/block/paride/pf.c:963 pf_init_unit() warn: missing error code
'ret'

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Yang Li <[email protected]>
---
drivers/block/paride/pcd.c | 3 ++-
drivers/block/paride/pf.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 4cc0d14..9ae8859 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -935,7 +935,8 @@ static int pcd_init_unit(struct pcd_unit *cd, bool autoprobe, int port,
if (!pi_init(cd->pi, autoprobe, port, mode, unit, protocol, delay,
pcd_buffer, PI_PCD, verbose, cd->name))
goto out_free_disk;
- if (pcd_probe(cd, ms))
+ ret = pcd_probe(cd, ms);
+ if (ret)
goto out_pi_release;

cd->present = 1;
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 380d80e..7b9acfc 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -959,7 +959,8 @@ static int __init pf_init_unit(struct pf_unit *pf, bool autoprobe, int port,
if (!pi_init(pf->pi, autoprobe, port, mode, unit, protocol, delay,
pf_scratch, PI_PF, verbose, pf->name))
goto out_free_disk;
- if (pf_probe(pf))
+ ret = pf_probe(pf);
+ if (ret)
goto out_pi_release;

ret = add_disk(disk);
--
1.8.3.1


2021-09-29 06:58:38

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH -next] pcd: capture error codes on pcd_probe() and pf_probe()

On Wed, Sep 29, 2021 at 02:40:29PM +0800, Yang Li wrote:
> No error code were being captured when pcd_probe() and
> pf_probe() fail, capture them by assigning them to ret.
>
> Clean up smatch warning:
> drivers/block/paride/pcd.c:939 pcd_init_unit() warn: missing error code
> 'ret'
> drivers/block/paride/pf.c:963 pf_init_unit() warn: missing error code
> 'ret'
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Yang Li <[email protected]>

Please not. I have a major rewrite of the paride probing pending,
which Jens just wanted to make conditional on potentially dropping the
drivers entirely. So either we take the real series to clean this mess
up or we drop the drivers, but we need to stop this sugarcoating of
fundamentally bad code.