Commit e0255aec authored by Linus Torvalds's avatar Linus Torvalds

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
parents ada7339e c9ddf734
......@@ -51,6 +51,8 @@ struct srp_internal {
struct transport_container rport_attr_cont;
};
static int scsi_is_srp_rport(const struct device *dev);
#define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
#define dev_to_rport(d) container_of(d, struct srp_rport, dev)
......@@ -60,9 +62,24 @@ static inline struct Scsi_Host *rport_to_shost(struct srp_rport *r)
return dev_to_shost(r->dev.parent);
}
static int find_child_rport(struct device *dev, void *data)
{
struct device **child = data;
if (scsi_is_srp_rport(dev)) {
WARN_ON_ONCE(*child);
*child = dev;
}
return 0;
}
static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
{
return transport_class_to_srp_rport(&shost->shost_gendev);
struct device *child = NULL;
WARN_ON_ONCE(device_for_each_child(&shost->shost_gendev, &child,
find_child_rport) < 0);
return child ? dev_to_rport(child) : NULL;
}
/**
......@@ -600,7 +617,8 @@ enum blk_eh_timer_return srp_timed_out(struct scsi_cmnd *scmd)
struct srp_rport *rport = shost_to_rport(shost);
pr_debug("timeout for sdev %s\n", dev_name(&sdev->sdev_gendev));
return rport->fast_io_fail_tmo < 0 && rport->dev_loss_tmo < 0 &&
return rport && rport->fast_io_fail_tmo < 0 &&
rport->dev_loss_tmo < 0 &&
i->f->reset_timer_if_blocked && scsi_device_blocked(sdev) ?
BLK_EH_RESET_TIMER : BLK_EH_NOT_HANDLED;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment