stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
To: Mukesh Ojha <mukesh02@linux.vnet.ibm.com>,
	mahesh@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] powerpc/powernv : Drop reference added by kset_find_obj()
Date: Mon, 22 Aug 2016 16:32:40 +0530	[thread overview]
Message-ID: <57BADBD0.3030405@linux.vnet.ibm.com> (raw)
In-Reply-To: <1471848464-5735-1-git-send-email-mukesh02@linux.vnet.ibm.com>

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 <mukesh02@linux.vnet.ibm.com>


I've reviewed and tested this patch. Looks good to me.

Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

-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);
>


      reply	other threads:[~2016-08-22 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22  6:47 [PATCH] powerpc/powernv : Drop reference added by kset_find_obj() Mukesh Ojha
2016-08-22 11:02 ` Vasant Hegde [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57BADBD0.3030405@linux.vnet.ibm.com \
    --to=hegdevasant@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=mukesh02@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).