public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] isa: Remove unnecessary checks
@ 2023-05-17 12:50 Vladislav Efanov
  2023-05-19  1:46 ` William Breathitt Gray
  0 siblings, 1 reply; 3+ messages in thread
From: Vladislav Efanov @ 2023-05-17 12:50 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: Vladislav Efanov, Greg Kroah-Hartman, Rafael J. Wysocki,
	Rene Herman, linux-kernel, lvc-project

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 <VEfanov@ispras.ru>
---
 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


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

* Re: [PATCH] isa: Remove unnecessary checks
  2023-05-17 12:50 [PATCH] isa: Remove unnecessary checks Vladislav Efanov
@ 2023-05-19  1:46 ` William Breathitt Gray
  2023-05-31 18:03   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: William Breathitt Gray @ 2023-05-19  1:46 UTC (permalink / raw)
  To: Vladislav Efanov, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Rene Herman, linux-kernel, lvc-project

[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]

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 <VEfanov@ispras.ru>

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 <william.gray@linaro.org>

> ---
>  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
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH] isa: Remove unnecessary checks
  2023-05-19  1:46 ` William Breathitt Gray
@ 2023-05-31 18:03   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2023-05-31 18:03 UTC (permalink / raw)
  To: William Breathitt Gray
  Cc: Vladislav Efanov, Rafael J. Wysocki, Rene Herman, linux-kernel,
	lvc-project

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 <VEfanov@ispras.ru>
> 
> 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 <william.gray@linaro.org>

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

greg k-h

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

end of thread, other threads:[~2023-05-31 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17 12:50 [PATCH] isa: Remove unnecessary checks Vladislav Efanov
2023-05-19  1:46 ` William Breathitt Gray
2023-05-31 18:03   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox