Skip to content

Commit 71458cf

Browse files
MukeshOjhagregkh
authored andcommitted
powerpc/powernv : Drop reference added by kset_find_obj()
commit a9cbf0b 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 <[email protected]> Reviewed-by: Vasant Hegde <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3a62e9f commit 71458cf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arch/powerpc/platforms/powernv/opal-dump.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ static irqreturn_t process_dump(int irq, void *data)
370370
uint32_t dump_id, dump_size, dump_type;
371371
struct dump_obj *dump;
372372
char name[22];
373+
struct kobject *kobj;
373374

374375
rc = dump_read_info(&dump_id, &dump_size, &dump_type);
375376
if (rc != OPAL_SUCCESS)
@@ -381,8 +382,12 @@ static irqreturn_t process_dump(int irq, void *data)
381382
* that gracefully and not create two conflicting
382383
* entries.
383384
*/
384-
if (kset_find_obj(dump_kset, name))
385+
kobj = kset_find_obj(dump_kset, name);
386+
if (kobj) {
387+
/* Drop reference added by kset_find_obj() */
388+
kobject_put(kobj);
385389
return 0;
390+
}
386391

387392
dump = create_dump_obj(dump_id, dump_size, dump_type);
388393
if (!dump)

arch/powerpc/platforms/powernv/opal-elog.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ static irqreturn_t elog_event(int irq, void *data)
247247
uint64_t elog_type;
248248
int rc;
249249
char name[2+16+1];
250+
struct kobject *kobj;
250251

251252
rc = opal_get_elog_size(&id, &size, &type);
252253
if (rc != OPAL_SUCCESS) {
@@ -269,8 +270,12 @@ static irqreturn_t elog_event(int irq, void *data)
269270
* that gracefully and not create two conflicting
270271
* entries.
271272
*/
272-
if (kset_find_obj(elog_kset, name))
273+
kobj = kset_find_obj(elog_kset, name);
274+
if (kobj) {
275+
/* Drop reference added by kset_find_obj() */
276+
kobject_put(kobj);
273277
return IRQ_HANDLED;
278+
}
274279

275280
create_elog_obj(log_id, elog_size, elog_type);
276281

0 commit comments

Comments
 (0)