Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=638d5bb8167c2c88552257d5af23f7f65ab4defd
Commit:     638d5bb8167c2c88552257d5af23f7f65ab4defd
Parent:     745647e7a2ae399f7f70aca47827e62c99c893b5
Author:     Stefan Richter <[EMAIL PROTECTED]>
AuthorDate: Sat Sep 15 14:45:53 2007 +0200
Committer:  Stefan Richter <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 23:59:58 2007 +0200

    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 <[EMAIL PROTECTED]>
---
 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 11712a3..ec8edd2 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
 {
        unsigned int ud_id = 0;
        struct csr1212_dentry *dentry;
-       struct csr1212_keyval *kv;
+       struct csr1212_keyval *kv, *vendor_name_kv = NULL;
        u8 last_key_id = 0;
 
        ne->needs_probe = 0;
@@ -1139,8 +1139,8 @@ static void nodemgr_process_root_directory(struct 
host_info *hi, struct node_ent
                                    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) 
== 0 &&
                                    
CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
                                    
CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) {
-                                       ne->vendor_name_kv = kv;
                                        csr1212_keep_keyval(kv);
+                                       vendor_name_kv = kv;
                                }
                        }
                        break;
@@ -1149,10 +1149,13 @@ static void nodemgr_process_root_directory(struct 
host_info *hi, struct node_ent
        }
 
        if (ne->vendor_name_kv) {
-               int error = device_create_file(&ne->device,
-                                              &dev_attr_ne_vendor_name_kv);
-
-               if (error && error != -EEXIST)
+               kv = ne->vendor_name_kv;
+               ne->vendor_name_kv = vendor_name_kv;
+               csr1212_release_keyval(kv);
+       } else if (vendor_name_kv) {
+               ne->vendor_name_kv = vendor_name_kv;
+               if (device_create_file(&ne->device,
+                                      &dev_attr_ne_vendor_name_kv) != 0)
                        HPSB_ERR("Failed to add sysfs attribute");
        }
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to