[PATCH 2/2] when we start up fcoe on an interface, check that
Ronnie Sahlberg
ronniesahlberg
Tue Jun 24 05:35:05 CEST 2008
we actually have an
interface name passed to us and print an error and return -ENODEV
othervise.
Othervise we will SEGV trying to memcpy() from a null pointer 1 line
further down.
When we initialize fcoe from the fcoe module, return proper success/failure
back to tgtd so that it can abort/fail if the low level driver failed
to initialize.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Signed-off-by: root <root at ubuntu-server-1.sahlberg.net>
---
usr/fcoe/fcoe_if.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/usr/fcoe/fcoe_if.c b/usr/fcoe/fcoe_if.c
index 906c30b..cc61408 100644
--- a/usr/fcoe/fcoe_if.c
+++ b/usr/fcoe/fcoe_if.c
@@ -164,6 +164,11 @@ int fcoe_create_interface(char *ifname)
/* todo */
fdev->fd_link_status = TRANS_LINK_UP;
+ if (!ifname) {
+ eprintf("no interface specified.\n");
+ return -ENODEV;
+ }
+
memcpy(fdev->ifname, ifname, IFNAMSIZ);
ret = fcoe_sock_open(fdev);
@@ -204,9 +209,7 @@ int fcoe_create_interface(char *ifname)
static int fcoe_init(int index, char *args)
{
eprintf("%s\n", args);
- fcoe_create_interface(args);
-
- return 0;
+ return fcoe_create_interface(args);
}
static struct tgt_driver fcoe = {
--
1.5.4.3
------=_Part_14803_1832293.1214781974773
Content-Type: application/x-gzip;
name=0002-when-we-start-up-fcoe-on-an-interface-check-that-we.patch.gz
Content-Transfer-Encoding: base64
X-Attachment-Id: f_fi29n8uh0
Content-Disposition: attachment;
filename=0002-when-we-start-up-fcoe-on-an-interface-check-that-we.patch.gz
RnJvbSBiNjlkOTdhOTg4OGZlMzZjM2E1NTJmZjY0YWZlMjQyMjRiZGI4ZjI3IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBSb25uaWUgU2FobGJlcmcgPHJvbm5pZXNhaGxiZXJnQGdtYWls
LmNvbT4KRGF0ZTogVHV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WYu
YwpAQCAtMTY0LDYgKzE2NCwxMSBAQCBpbnQgZmNvZV9jcmVhdGVfaW50ZXJmYWNlKGNoYXIgKmlm
bmFtZSkKIAkvKiB0b2RvICovCiAJZmRldi0+ZmRfbGlua19zdGF0dXMgPSBUUkFOU19MSU5LX1VQ
OwogCisJaWYgKCFpZm5hbWUpIHsKKwkJZXByaW50Zigibm8gaW50ZXJmYWNlIHNwZWNpZmllZC5c
biIpOworCQlyZXR1cm4gLUVOT0RFVjsKKwl9CisKIAltZW1jcHkoZmRldi0+aWZuYW1lLCBpZm5h
bWUsIElGTkFNU0laKTsKIAogCXJldCA9IGZjb2Vfc29ja19vcGVuKGZkZXYpOwpAQCAtMjA0LDkg
KzIwOSw3IEBAIGludCBmY29lX2NyZWF0ZV9pbnRlcmZhY2UoY2hhciAqaWZuYW1lKQogc3RhdGlj
IGludCBmY29lX2luaXQoaW50IGluZGV4LCBjaGFyICphcmdzKQogewogCWVwcmludGYoIiVzXG4i
LCBhcmdzKTsKLQlmY29lX2NyZWF0ZV9pbnRlcmZhY2UoYXJncyk7Ci0KLQlyZXR1cm4gMDsKKwly
ZXR1cm4gZmNvZV9jcmVhdGVfaW50ZXJmYWNlKGFyZ3MpOwogfQogCiBzdGF0aWMgc3RydWN0IHRn
dF9kcml2ZXIgZmNvZSA9IHsKLS0gCjEuNS40LjMKCg==
------=_Part_14803_1832293.1214781974773--
More information about the stgt
mailing list