diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2007-09-15 08:45:53 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2007-10-16 17:59:58 -0400 |
commit | 638d5bb8167c2c88552257d5af23f7f65ab4defd (patch) | |
tree | 736f9e4fab8d5c086a889dadebe7d6d02f4bf0a5 | |
parent | 745647e7a2ae399f7f70aca47827e62c99c893b5 (diff) |
ieee1394: nodemgr: fix leak of struct csr1212_keyval
csr1212_keep_keyval(kv) in nodemgr_process_root_directory was
unbalanced if ne->vendor_name_kv already exists. This happens for
example if eth1394 or raw1394 modify the local config ROM and it is
parsed again.
As a bonus, the attempt to add the vendor_name_kv sysfs attribute
when it already exists is now fixed for good.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/ieee1394/nodemgr.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 11712a3ae0ad..ec8edd2f19de 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -1112,7 +1112,7 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent | |||
1112 | { | 1112 | { |
1113 | unsigned int ud_id = 0; | 1113 | unsigned int ud_id = 0; |
1114 | struct csr1212_dentry *dentry; | 1114 | struct csr1212_dentry *dentry; |
1115 | struct csr1212_keyval *kv; | 1115 | struct csr1212_keyval *kv, *vendor_name_kv = NULL; |
1116 | u8 last_key_id = 0; | 1116 | u8 last_key_id = 0; |
1117 | 1117 | ||
1118 | ne->needs_probe = 0; | 1118 | ne->needs_probe = 0; |
@@ -1139,8 +1139,8 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent | |||
1139 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && | 1139 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 && |
1140 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && | 1140 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 && |
1141 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) { | 1141 | CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) { |
1142 | ne->vendor_name_kv = kv; | ||
1143 | csr1212_keep_keyval(kv); | 1142 | csr1212_keep_keyval(kv); |
1143 | vendor_name_kv = kv; | ||
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | break; | 1146 | break; |
@@ -1149,10 +1149,13 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent | |||
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | if (ne->vendor_name_kv) { | 1151 | if (ne->vendor_name_kv) { |
1152 | int error = device_create_file(&ne->device, | 1152 | kv = ne->vendor_name_kv; |
1153 | &dev_attr_ne_vendor_name_kv); | 1153 | ne->vendor_name_kv = vendor_name_kv; |
1154 | 1154 | csr1212_release_keyval(kv); | |
1155 | if (error && error != -EEXIST) | 1155 | } else if (vendor_name_kv) { |
1156 | ne->vendor_name_kv = vendor_name_kv; | ||
1157 | if (device_create_file(&ne->device, | ||
1158 | &dev_attr_ne_vendor_name_kv) != 0) | ||
1156 | HPSB_ERR("Failed to add sysfs attribute"); | 1159 | HPSB_ERR("Failed to add sysfs attribute"); |
1157 | } | 1160 | } |
1158 | } | 1161 | } |