diff options
author | Joe Eykholt <jeykholt@cisco.com> | 2009-08-25 17:02:43 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-09-10 13:07:52 -0400 |
commit | 81a67b9717d9e4f81bed7d1f2df6ba86aaab9ad9 (patch) | |
tree | 92c6e4bd45b71f48e8db60996bda724ef79246ad /drivers/scsi | |
parent | 3667d7e7f7bb63a394f73a671fdaf4a187aa858e (diff) |
[SCSI] libfc: discovery gpn_ft parse bug
In fc_disc_gpn_ft_parse(), after fc_disc_done() is called, the
disc state is changed by setting buf_len = 0. This is wrong
since the discovery may have restarted. Instead, return
after calling fc_disc_done.
Also, return an error on memory allocation failure.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libfc/fc_disc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index 3efdbbab9b2b..a2410dc74441 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -479,6 +479,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
479 | plen = len; | 479 | plen = len; |
480 | np = (struct fc_gpn_ft_resp *)bp; | 480 | np = (struct fc_gpn_ft_resp *)bp; |
481 | tlen = disc->buf_len; | 481 | tlen = disc->buf_len; |
482 | disc->buf_len = 0; | ||
482 | if (tlen) { | 483 | if (tlen) { |
483 | WARN_ON(tlen >= sizeof(*np)); | 484 | WARN_ON(tlen >= sizeof(*np)); |
484 | plen = sizeof(*np) - tlen; | 485 | plen = sizeof(*np) - tlen; |
@@ -519,10 +520,12 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
519 | rdata = lport->tt.rport_create(lport, &ids); | 520 | rdata = lport->tt.rport_create(lport, &ids); |
520 | if (rdata) | 521 | if (rdata) |
521 | rdata->disc_id = disc->disc_id; | 522 | rdata->disc_id = disc->disc_id; |
522 | else | 523 | else { |
523 | printk(KERN_WARNING "libfc: Failed to allocate " | 524 | printk(KERN_WARNING "libfc: Failed to allocate " |
524 | "memory for the newly discovered port " | 525 | "memory for the newly discovered port " |
525 | "(%6x)\n", ids.port_id); | 526 | "(%6x)\n", ids.port_id); |
527 | error = -ENOMEM; | ||
528 | } | ||
526 | } | 529 | } |
527 | 530 | ||
528 | if (np->fp_flags & FC_NS_FID_LAST) { | 531 | if (np->fp_flags & FC_NS_FID_LAST) { |
@@ -546,8 +549,6 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) | |||
546 | memcpy(&disc->partial_buf, np, len); | 549 | memcpy(&disc->partial_buf, np, len); |
547 | } | 550 | } |
548 | disc->buf_len = (unsigned char) len; | 551 | disc->buf_len = (unsigned char) len; |
549 | } else { | ||
550 | disc->buf_len = 0; | ||
551 | } | 552 | } |
552 | return error; | 553 | return error; |
553 | } | 554 | } |