Commit 390178a3 authored by Joe Eykholt's avatar Joe Eykholt Committed by James Bottomley

[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: default avatarJoe Eykholt <jeykholt@cisco.com>
Signed-off-by: default avatarRobert Love <robert.w.love@intel.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 86717f30
...@@ -479,6 +479,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len) ...@@ -479,6 +479,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
plen = len; plen = len;
np = (struct fc_gpn_ft_resp *)bp; np = (struct fc_gpn_ft_resp *)bp;
tlen = disc->buf_len; tlen = disc->buf_len;
disc->buf_len = 0;
if (tlen) { if (tlen) {
WARN_ON(tlen >= sizeof(*np)); WARN_ON(tlen >= sizeof(*np));
plen = sizeof(*np) - tlen; 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,10 +520,12 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
rdata = lport->tt.rport_create(lport, &ids); rdata = lport->tt.rport_create(lport, &ids);
if (rdata) if (rdata)
rdata->disc_id = disc->disc_id; rdata->disc_id = disc->disc_id;
else else {
printk(KERN_WARNING "libfc: Failed to allocate " printk(KERN_WARNING "libfc: Failed to allocate "
"memory for the newly discovered port " "memory for the newly discovered port "
"(%6x)\n", ids.port_id); "(%6x)\n", ids.port_id);
error = -ENOMEM;
}
} }
if (np->fp_flags & FC_NS_FID_LAST) { 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,8 +549,6 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
memcpy(&disc->partial_buf, np, len); memcpy(&disc->partial_buf, np, len);
} }
disc->buf_len = (unsigned char) len; disc->buf_len = (unsigned char) len;
} else {
disc->buf_len = 0;
} }
return error; return error;
} }
......
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