Merge tag 'for-v3.8' of git://git.infradead.org/users/cbou/linux-pstore
[firefly-linux-kernel-4.4.55.git] / drivers / ata / libata-scsi.c
index a6df6a351d6e4ce263f717ad52bf1ebb72a1aae0..7c337e754dab30cf63c1b8a8b28c416f535bd86f 100644 (file)
@@ -309,7 +309,8 @@ ata_scsi_activity_show(struct device *dev, struct device_attribute *attr,
        struct ata_port *ap = ata_shost_to_port(sdev->host);
        struct ata_device *atadev = ata_scsi_find_dev(ap, sdev);
 
-       if (ap->ops->sw_activity_show && (ap->flags & ATA_FLAG_SW_ACTIVITY))
+       if (atadev && ap->ops->sw_activity_show &&
+           (ap->flags & ATA_FLAG_SW_ACTIVITY))
                return ap->ops->sw_activity_show(atadev, buf);
        return -EINVAL;
 }
@@ -324,7 +325,8 @@ ata_scsi_activity_store(struct device *dev, struct device_attribute *attr,
        enum sw_activity val;
        int rc;
 
-       if (ap->ops->sw_activity_store && (ap->flags & ATA_FLAG_SW_ACTIVITY)) {
+       if (atadev && ap->ops->sw_activity_store &&
+           (ap->flags & ATA_FLAG_SW_ACTIVITY)) {
                val = simple_strtoul(buf, NULL, 0);
                switch (val) {
                case OFF: case BLINK_ON: case BLINK_OFF: