]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
powerpc/powernv : Drop reference added by kset_find_obj()
authorMukesh Ojha <mukesh02@linux.vnet.ibm.com>
Mon, 22 Aug 2016 06:47:44 +0000 (12:17 +0530)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 20 Nov 2016 01:17:19 +0000 (01:17 +0000)
commit a9cbf0b2195b695cbeeeecaa4e2770948c212e9a upstream.

In a situation, where Linux kernel gets notified about duplicate error log
from OPAL, it is been observed that kernel fails to remove sysfs entries
(/sys/firmware/opal/elog/0xXXXXXXXX) of such error logs. This is because,
we currently search the error log/dump kobject in the kset list via
'kset_find_obj()' routine. Which eventually increment the reference count
by one, once it founds the kobject.

So, unless we decrement the reference count by one after it found the kobject,
we would not be able to release the kobject properly later.

This patch adds the 'kobject_put()' which was missing earlier.

Signed-off-by: Mukesh Ojha <mukesh02@linux.vnet.ibm.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/powerpc/platforms/powernv/opal-dump.c
arch/powerpc/platforms/powernv/opal-elog.c

index 788a1977b9a5203cc9a477be6f9a2a7b71cdd754..2f420f9e4c5405198c694e73b23fe9139e497f30 100644 (file)
@@ -365,6 +365,7 @@ static int process_dump(void)
        uint32_t dump_id, dump_size, dump_type;
        struct dump_obj *dump;
        char name[22];
+       struct kobject *kobj;
 
        rc = dump_read_info(&dump_id, &dump_size, &dump_type);
        if (rc != OPAL_SUCCESS)
@@ -376,8 +377,12 @@ static int process_dump(void)
         * that gracefully and not create two conflicting
         * entries.
         */
-       if (kset_find_obj(dump_kset, name))
+       kobj = kset_find_obj(dump_kset, name);
+       if (kobj) {
+               /* Drop reference added by kset_find_obj() */
+               kobject_put(kobj);
                return 0;
+       }
 
        dump = create_dump_obj(dump_id, dump_size, dump_type);
        if (!dump)
index 0ad533b617f7888e5c45c27fd7ad4e7671e80f8c..c4ae2958de9c9f004c9ab5176f61299db0cf8fbf 100644 (file)
@@ -246,6 +246,7 @@ static void elog_work_fn(struct work_struct *work)
        uint64_t elog_type;
        int rc;
        char name[2+16+1];
+       struct kobject *kobj;
 
        rc = opal_get_elog_size(&id, &size, &type);
        if (rc != OPAL_SUCCESS) {
@@ -268,8 +269,12 @@ static void elog_work_fn(struct work_struct *work)
         * that gracefully and not create two conflicting
         * entries.
         */
-       if (kset_find_obj(elog_kset, name))
+       kobj = kset_find_obj(elog_kset, name);
+       if (kobj) {
+               /* Drop reference added by kset_find_obj() */
+               kobject_put(kobj);
                return;
+       }
 
        create_elog_obj(log_id, elog_size, elog_type);
 }