Commit 60817a680b1bd3341b6909fab7d8a1fcc3a78369

Authored by Aaron Lu
Committed by Jeff Garzik
1 parent c5e35d6c51

libata-acpi: Fix NULL ptr derference in ata_acpi_dev_handle

commit 6b66d95895c149cbc04d4fac5a2f5477c543a8ae didn't handle SATA PMP
case in ata_acpi_bind_device and will cause a NULL ptr dereference when
user attached a SATA drive to the PMP port. Fix this by checking PMP
support.

This bug is reported by Dan van der Ster in the following bugzilla page:
https://bugzilla.kernel.org/show_bug.cgi?id=48211

Reported-by: Dan van der Ster <dan@vanderster.com>
Tested-by: Dan van der Ster <dan@vanderster.com>
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Tested-by: Simon <tangouniform@sbcglobal.net>

Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff

drivers/ata/libata-acpi.c
... ... @@ -1105,10 +1105,15 @@
1105 1105 struct acpi_device *acpi_dev;
1106 1106 struct acpi_device_power_state *states;
1107 1107  
1108   - if (ap->flags & ATA_FLAG_ACPI_SATA)
1109   - ata_dev = &ap->link.device[sdev->channel];
1110   - else
  1108 + if (ap->flags & ATA_FLAG_ACPI_SATA) {
  1109 + if (!sata_pmp_attached(ap))
  1110 + ata_dev = &ap->link.device[sdev->id];
  1111 + else
  1112 + ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id];
  1113 + }
  1114 + else {
1111 1115 ata_dev = &ap->link.device[sdev->id];
  1116 + }
1112 1117  
1113 1118 *handle = ata_dev_acpi_handle(ata_dev);
1114 1119