Linux ATA/IDE development
 help / color / mirror / Atom feed
* [PATCH] ata: pata_legacy: make legacy_exit() work again
@ 2024-05-04 20:27 Sergey Shtylyov
  2024-05-06 16:37 ` Niklas Cassel
  2024-05-06 22:28 ` Damien Le Moal
  0 siblings, 2 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2024-05-04 20:27 UTC (permalink / raw)
  To: linux-ide, Damien Le Moal, Niklas Cassel; +Cc: lvc-project

Commit defc9cd826e4 ("pata_legacy: resychronize with upstream changes and
resubmit") missed to update legacy_exit(), so that it now fails to do any
cleanup -- the loop body there can never be entered.  Fix that and finally
remove now useless nr_legacy_host variable...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Fixes: defc9cd826e4 ("pata_legacy: resychronize with upstream changes and resubmit")
Cc: stable@vger.kernel.org
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the master branch of the LibATA Group's linux.git repo.
It's only been build-tested...

 drivers/ata/pata_legacy.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: linux/drivers/ata/pata_legacy.c
===================================================================
--- linux.orig/drivers/ata/pata_legacy.c
+++ linux/drivers/ata/pata_legacy.c
@@ -173,8 +173,6 @@ static int legacy_port[NR_HOST] = { 0x1f
 static struct legacy_probe probe_list[NR_HOST];
 static struct legacy_data legacy_data[NR_HOST];
 static struct ata_host *legacy_host[NR_HOST];
-static int nr_legacy_host;
-
 
 /**
  *	legacy_probe_add	-	Add interface to probe list
@@ -1276,9 +1274,11 @@ static __exit void legacy_exit(void)
 {
 	int i;
 
-	for (i = 0; i < nr_legacy_host; i++) {
+	for (i = 0; i < NR_HOST; i++) {
 		struct legacy_data *ld = &legacy_data[i];
-		ata_host_detach(legacy_host[i]);
+
+		if (legacy_host[i])
+			ata_host_detach(legacy_host[i]);
 		platform_device_unregister(ld->platform_dev);
 	}
 }

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

* Re: [PATCH] ata: pata_legacy: make legacy_exit() work again
  2024-05-04 20:27 [PATCH] ata: pata_legacy: make legacy_exit() work again Sergey Shtylyov
@ 2024-05-06 16:37 ` Niklas Cassel
  2024-05-06 22:28 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Cassel @ 2024-05-06 16:37 UTC (permalink / raw)
  To: Sergey Shtylyov; +Cc: linux-ide, Damien Le Moal, lvc-project

On Sat, May 04, 2024 at 11:27:25PM +0300, Sergey Shtylyov wrote:
> Commit defc9cd826e4 ("pata_legacy: resychronize with upstream changes and
> resubmit") missed to update legacy_exit(), so that it now fails to do any
> cleanup -- the loop body there can never be entered.  Fix that and finally
> remove now useless nr_legacy_host variable...
> 
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
> 
> Fixes: defc9cd826e4 ("pata_legacy: resychronize with upstream changes and resubmit")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> ---
> This patch is against the master branch of the LibATA Group's linux.git repo.
> It's only been build-tested...
> 
>  drivers/ata/pata_legacy.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> Index: linux/drivers/ata/pata_legacy.c
> ===================================================================
> --- linux.orig/drivers/ata/pata_legacy.c
> +++ linux/drivers/ata/pata_legacy.c
> @@ -173,8 +173,6 @@ static int legacy_port[NR_HOST] = { 0x1f
>  static struct legacy_probe probe_list[NR_HOST];
>  static struct legacy_data legacy_data[NR_HOST];
>  static struct ata_host *legacy_host[NR_HOST];
> -static int nr_legacy_host;
> -
>  
>  /**
>   *	legacy_probe_add	-	Add interface to probe list
> @@ -1276,9 +1274,11 @@ static __exit void legacy_exit(void)
>  {
>  	int i;
>  
> -	for (i = 0; i < nr_legacy_host; i++) {
> +	for (i = 0; i < NR_HOST; i++) {
>  		struct legacy_data *ld = &legacy_data[i];
> -		ata_host_detach(legacy_host[i]);
> +
> +		if (legacy_host[i])
> +			ata_host_detach(legacy_host[i]);
>  		platform_device_unregister(ld->platform_dev);
>  	}
>  }

Reviewed-by: Niklas Cassel <cassel@kernel.org>

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

* Re: [PATCH] ata: pata_legacy: make legacy_exit() work again
  2024-05-04 20:27 [PATCH] ata: pata_legacy: make legacy_exit() work again Sergey Shtylyov
  2024-05-06 16:37 ` Niklas Cassel
@ 2024-05-06 22:28 ` Damien Le Moal
  1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2024-05-06 22:28 UTC (permalink / raw)
  To: Sergey Shtylyov, linux-ide, Niklas Cassel; +Cc: lvc-project

On 5/5/24 05:27, Sergey Shtylyov wrote:
> Commit defc9cd826e4 ("pata_legacy: resychronize with upstream changes and
> resubmit") missed to update legacy_exit(), so that it now fails to do any
> cleanup -- the loop body there can never be entered.  Fix that and finally
> remove now useless nr_legacy_host variable...
> 
> Found by Linux Verification Center (linuxtesting.org) with the Svace static
> analysis tool.
> 
> Fixes: defc9cd826e4 ("pata_legacy: resychronize with upstream changes and resubmit")
> Cc: stable@vger.kernel.org
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

Applied to for-6.10. Thanks !

-- 
Damien Le Moal
Western Digital Research


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

end of thread, other threads:[~2024-05-06 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-04 20:27 [PATCH] ata: pata_legacy: make legacy_exit() work again Sergey Shtylyov
2024-05-06 16:37 ` Niklas Cassel
2024-05-06 22:28 ` Damien Le Moal

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