Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fix from James Bottomley:
"Eve of merge window fix: The original code was so bogus as to be
casting the wrong generic device to an rport and proceeding to take
actions based on the bogus values it found.

Fortunately it seems the location that is dereferenced always exists,
so the code hasn't oopsed yet, but it certainly annoys the memory
checkers"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: scsi_transport_srp: Fix shost to rport translation

Changed files
+20 -2
drivers
+20 -2
drivers/scsi/scsi_transport_srp.c
··· 51 51 struct transport_container rport_attr_cont; 52 52 }; 53 53 54 + static int scsi_is_srp_rport(const struct device *dev); 55 + 54 56 #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) 55 57 56 58 #define dev_to_rport(d) container_of(d, struct srp_rport, dev) ··· 62 60 return dev_to_shost(r->dev.parent); 63 61 } 64 62 63 + static int find_child_rport(struct device *dev, void *data) 64 + { 65 + struct device **child = data; 66 + 67 + if (scsi_is_srp_rport(dev)) { 68 + WARN_ON_ONCE(*child); 69 + *child = dev; 70 + } 71 + return 0; 72 + } 73 + 65 74 static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost) 66 75 { 67 - return transport_class_to_srp_rport(&shost->shost_gendev); 76 + struct device *child = NULL; 77 + 78 + WARN_ON_ONCE(device_for_each_child(&shost->shost_gendev, &child, 79 + find_child_rport) < 0); 80 + return child ? dev_to_rport(child) : NULL; 68 81 } 69 82 70 83 /** ··· 617 600 struct srp_rport *rport = shost_to_rport(shost); 618 601 619 602 pr_debug("timeout for sdev %s\n", dev_name(&sdev->sdev_gendev)); 620 - return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 && 603 + return rport && rport->fast_io_fail_tmo < 0 && 604 + rport->dev_loss_tmo < 0 && 621 605 i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ? 622 606 BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED; 623 607 }