mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name
Date: Wed, 27 Sep 2017 15:29:57 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1709271521060.2027@nanos> (raw)
In-Reply-To: <20170927122816.18931-1-jeffy.chen@rock-chips.com>

On Wed, 27 Sep 2017, Jeffy Chen wrote:

> Free domain->name when IRQ_DOMAIN_NAME_ALLOCATED been set.

I can see that from the patch, but you fail to explain what the problem
is.

It's actually more than just a memory leak. If the domain gets destroyed
then the domain free code would try to free d->name which might be a string
constant .....

> +	if (d->flags & IRQ_DOMAIN_NAME_ALLOCATED) {
> +		kfree(d->name);
> +		d->flags &= ~IRQ_DOMAIN_NAME_ALLOCATED;
> +	}
>  	d->name = name;

I don't think that this is the proper thing to do. There is no reason why
the domain should have the same name as the irq chip. So we rather should
do:

	if (!d->name)
		d->name = name;

Along with a proper comment.

Thanks,

	tglx

  reply	other threads:[~2017-09-27 13:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 12:28 Jeffy Chen
2017-09-27 13:29 ` Thomas Gleixner [this message]
2017-09-28  3:18   ` jeffy
2017-09-28  4:36     ` jeffy

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=alpine.DEB.2.20.1709271521060.2027@nanos \
    --to=tglx@linutronix.de \
    --cc=jeffy.chen@rock-chips.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®