2023-05-17 13:00:05

by Vladislav Efanov

[permalink] [raw]
Subject: [PATCH] isa: Remove unnecessary checks

The isa_dev->dev.platform_data is initialized with incoming
parameter isa_driver. After it isa_dev->dev.platform_data is
checked for NULL, but incoming parameter isa_driver is not
NULL since it is dereferenced many times before this check.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: a5117ba7da37 ("[PATCH] Driver model: add ISA bus")
Signed-off-by: Vladislav Efanov <[email protected]>
---
drivers/base/isa.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index 55e3ee2da98f..675ad3139224 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -149,11 +149,8 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev)
break;
}

- if (isa_dev->dev.platform_data) {
- isa_dev->next = isa_driver->devices;
- isa_driver->devices = &isa_dev->dev;
- } else
- device_unregister(&isa_dev->dev);
+ isa_dev->next = isa_driver->devices;
+ isa_driver->devices = &isa_dev->dev;
}

if (!error && !isa_driver->devices)
--
2.34.1



2023-05-19 02:06:36

by William Breathitt Gray

[permalink] [raw]
Subject: Re: [PATCH] isa: Remove unnecessary checks

On Wed, May 17, 2023 at 03:50:25PM +0300, Vladislav Efanov wrote:
> The isa_dev->dev.platform_data is initialized with incoming
> parameter isa_driver. After it isa_dev->dev.platform_data is
> checked for NULL, but incoming parameter isa_driver is not
> NULL since it is dereferenced many times before this check.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: a5117ba7da37 ("[PATCH] Driver model: add ISA bus")
> Signed-off-by: Vladislav Efanov <[email protected]>

I don't think the Fixes line is needed because this is removing a
superfluous check rather than fixing a bug. Regardless, here's my Ack
for Greg as the patch itself makes sense.

Acked-by: William Breathitt Gray <[email protected]>

> ---
> drivers/base/isa.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/isa.c b/drivers/base/isa.c
> index 55e3ee2da98f..675ad3139224 100644
> --- a/drivers/base/isa.c
> +++ b/drivers/base/isa.c
> @@ -149,11 +149,8 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev)
> break;
> }
>
> - if (isa_dev->dev.platform_data) {
> - isa_dev->next = isa_driver->devices;
> - isa_driver->devices = &isa_dev->dev;
> - } else
> - device_unregister(&isa_dev->dev);
> + isa_dev->next = isa_driver->devices;
> + isa_driver->devices = &isa_dev->dev;
> }
>
> if (!error && !isa_driver->devices)
> --
> 2.34.1
>


Attachments:
(No filename) (1.44 kB)
signature.asc (235.00 B)
Download all attachments

2023-05-31 18:17:39

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] isa: Remove unnecessary checks

On Thu, May 18, 2023 at 09:46:21PM -0400, William Breathitt Gray wrote:
> On Wed, May 17, 2023 at 03:50:25PM +0300, Vladislav Efanov wrote:
> > The isa_dev->dev.platform_data is initialized with incoming
> > parameter isa_driver. After it isa_dev->dev.platform_data is
> > checked for NULL, but incoming parameter isa_driver is not
> > NULL since it is dereferenced many times before this check.
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Fixes: a5117ba7da37 ("[PATCH] Driver model: add ISA bus")
> > Signed-off-by: Vladislav Efanov <[email protected]>
>
> I don't think the Fixes line is needed because this is removing a
> superfluous check rather than fixing a bug. Regardless, here's my Ack
> for Greg as the patch itself makes sense.
>
> Acked-by: William Breathitt Gray <[email protected]>

Yes, the Fixes line makes no sense at all. I'll delete it when
applying, thanks for the review.

greg k-h