diff options
-rw-r--r-- | drivers/ata/libata-core.c | 19 | ||||
-rw-r--r-- | include/linux/libata.h | 2 |
2 files changed, 15 insertions, 6 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index f368387829ca..c831c9efee60 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -5792,13 +5792,18 @@ static struct ata_port * ata_port_add(const struct ata_probe_ent *ent, | |||
5792 | return NULL; | 5792 | return NULL; |
5793 | } | 5793 | } |
5794 | 5794 | ||
5795 | shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); | 5795 | ap = kzalloc(sizeof(struct ata_port), GFP_KERNEL); |
5796 | if (!shost) | 5796 | if (!ap) |
5797 | return NULL; | 5797 | return NULL; |
5798 | 5798 | ||
5799 | shost->transportt = &ata_scsi_transport_template; | 5799 | shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port *)); |
5800 | if (!shost) { | ||
5801 | kfree(ap); | ||
5802 | return NULL; | ||
5803 | } | ||
5800 | 5804 | ||
5801 | ap = ata_shost_to_port(shost); | 5805 | *(struct ata_port **)&shost->hostdata[0] = ap; |
5806 | shost->transportt = &ata_scsi_transport_template; | ||
5802 | 5807 | ||
5803 | ata_port_init(ap, host, ent, port_no); | 5808 | ata_port_init(ap, host, ent, port_no); |
5804 | ata_port_init_shost(ap, shost); | 5809 | ata_port_init_shost(ap, shost); |
@@ -5824,9 +5829,13 @@ static void ata_host_release(struct device *gendev, void *res) | |||
5824 | for (i = 0; i < host->n_ports; i++) { | 5829 | for (i = 0; i < host->n_ports; i++) { |
5825 | struct ata_port *ap = host->ports[i]; | 5830 | struct ata_port *ap = host->ports[i]; |
5826 | 5831 | ||
5827 | if (ap) | 5832 | if (!ap) |
5833 | continue; | ||
5834 | |||
5835 | if (ap->scsi_host) | ||
5828 | scsi_host_put(ap->scsi_host); | 5836 | scsi_host_put(ap->scsi_host); |
5829 | 5837 | ||
5838 | kfree(ap); | ||
5830 | host->ports[i] = NULL; | 5839 | host->ports[i] = NULL; |
5831 | } | 5840 | } |
5832 | 5841 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index 12237d4b9f9b..ced9dd54035e 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -1231,7 +1231,7 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev) | |||
1231 | 1231 | ||
1232 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) | 1232 | static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host) |
1233 | { | 1233 | { |
1234 | return (struct ata_port *) &host->hostdata[0]; | 1234 | return *(struct ata_port **)&host->hostdata[0]; |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | #endif /* __LINUX_LIBATA_H__ */ | 1237 | #endif /* __LINUX_LIBATA_H__ */ |