Fix 2 bugs in iscsi_attr_replace() sent by Lev Vainblat <lev@zadarastorage.com>:

1. After attr was found in the attrs_list, it is inserted again back into the same list. As a result the list becomes corrupted.

The bug can be reproduced for example by the following sequence:

    $ echo add_attribute IncomingUser user secret111111 > /sys/kernel/scst_tgt/targets/iscsi/mgmt
    $ echo user secret222222 > /sys/kernel/scst_tgt/targets/iscsi/IncomingUser
    $ echo del_attribute IncomingUser user > /sys/kernel/scst_tgt/targets/iscsi/mgmt
    $ iscsiadm -m discovery -t st -p 127.0.0.1

Discovery fails and in syslog there is a message

    Oct  2 18:58:37 vsa-00000611 iscsi-scstd: [1059] cmnd_exec_login:940: ERROR: Authentication of initiator iqn.2011-04.com.zadarastorage:1553:vc-0 failed

2. Small memory leak in error recovery path.



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4545 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2012-10-04 18:34:25 +00:00
parent 3e36bb0357
commit 57d7bcd809
+1 -2
View File
@@ -195,8 +195,6 @@ int iscsi_attr_replace(struct __qelem *attrs_list, const char *sysfs_name,
a = iscsi_attr_lookup_by_key(attrs_list, key);
list_add_tail(attr, attrs_list);
if ((a != NULL) && (a != attr)) {
log_error("Attr %s (sysfs_name %s) already exists\n", key,
a->sysfs_name);
@@ -216,6 +214,7 @@ int iscsi_attr_replace(struct __qelem *attrs_list, const char *sysfs_name,
if (new_val == NULL) {
log_error("Unable to duplicate attr_value %s", val);
res = -ENOMEM;
free(new_key);
goto out;
}
} else