Patchwork ATA: fix a problem that ata port print_id is used uninitialized

login
register
mail settings
Submitter Zhang Rui
Date July 30, 2009, 1:11 a.m.
Message ID <1248916316.2670.160.camel@rzhang-dt>
Download mbox | patch
Permalink /patch/30374/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Zhang Rui - July 30, 2009, 1:11 a.m.
fix a problem that ata port print_id is used uninitialized.

port print_id is initialized in ata_host_register, but it's
used in ata_host_start.
Now move it to ata_host_start, before it's invoked for the first time.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/ata/libata-core.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tejun Heo - July 30, 2009, 4:33 a.m.
Zhang Rui wrote:
> fix a problem that ata port print_id is used uninitialized.
> 
> port print_id is initialized in ata_host_register, but it's
> used in ata_host_start.
> Now move it to ata_host_start, before it's invoked for the first time.
> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>

The idea was to assign print_id after the port is pretty much
guaranteed to be registered successfully but doing it earlier
shouldn't harm anything really.  So,

Acked-by: Tejun Heo <tj@kernel.org>

Patch

Index: linux-2.6/drivers/ata/libata-core.c
===================================================================
--- linux-2.6.orig/drivers/ata/libata-core.c
+++ linux-2.6/drivers/ata/libata-core.c
@@ -5963,6 +5963,8 @@  int ata_host_start(struct ata_host *host
 	for (i = 0; i < host->n_ports; i++) {
 		struct ata_port *ap = host->ports[i];
 
+		host->ports[i]->print_id = ata_print_id++;
+
 		if (ap->ops->port_start) {
 			rc = ap->ops->port_start(ap);
 			if (rc) {
@@ -6107,10 +6109,6 @@  int ata_host_register(struct ata_host *h
 	for (i = host->n_ports; host->ports[i]; i++)
 		kfree(host->ports[i]);
 
-	/* give ports names and add SCSI hosts */
-	for (i = 0; i < host->n_ports; i++)
-		host->ports[i]->print_id = ata_print_id++;
-
 	rc = ata_scsi_add_hosts(host, sht);
 	if (rc)
 		return rc;