From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:11939 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753964AbcHVLCw (ORCPT ); Mon, 22 Aug 2016 07:02:52 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u7MAxdcs131353 for ; Mon, 22 Aug 2016 07:02:51 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0b-001b2d01.pphosted.com with ESMTP id 24y63b3bxg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 22 Aug 2016 07:02:50 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Aug 2016 21:02:47 +1000 Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 9000A2CE8046 for ; Mon, 22 Aug 2016 21:02:43 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u7MB2hGv32309392 for ; Mon, 22 Aug 2016 21:02:43 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u7MB2he4008243 for ; Mon, 22 Aug 2016 21:02:43 +1000 Subject: Re: [PATCH] powerpc/powernv : Drop reference added by kset_find_obj() To: Mukesh Ojha , mahesh@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org References: <1471848464-5735-1-git-send-email-mukesh02@linux.vnet.ibm.com> Cc: stable@vger.kernel.org From: Vasant Hegde Date: Mon, 22 Aug 2016 16:32:40 +0530 MIME-Version: 1.0 In-Reply-To: <1471848464-5735-1-git-send-email-mukesh02@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-Id: <57BADBD0.3030405@linux.vnet.ibm.com> Sender: stable-owner@vger.kernel.org List-ID: On 08/22/2016 12:17 PM, Mukesh Ojha wrote: > 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 I've reviewed and tested this patch. Looks good to me. Reviewed-by: Vasant Hegde -Vasant > Cc: stable@vger.kernel.org > --- > arch/powerpc/platforms/powernv/opal-dump.c | 7 ++++++- > arch/powerpc/platforms/powernv/opal-elog.c | 7 ++++++- > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c > index 2ee9643..4c82782 100644 > --- a/arch/powerpc/platforms/powernv/opal-dump.c > +++ b/arch/powerpc/platforms/powernv/opal-dump.c > @@ -370,6 +370,7 @@ static irqreturn_t process_dump(int irq, void *data) > 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) > @@ -381,8 +382,12 @@ static irqreturn_t process_dump(int irq, void *data) > * 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) > diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c > index 37f959b..f2344cb 100644 > --- a/arch/powerpc/platforms/powernv/opal-elog.c > +++ b/arch/powerpc/platforms/powernv/opal-elog.c > @@ -247,6 +247,7 @@ static irqreturn_t elog_event(int irq, void *data) > 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) { > @@ -269,8 +270,12 @@ static irqreturn_t elog_event(int irq, void *data) > * 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 IRQ_HANDLED; > + } > > create_elog_obj(log_id, elog_size, elog_type); >