From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752642AbdI1DSy (ORCPT ); Wed, 27 Sep 2017 23:18:54 -0400 Received: from regular1.263xmail.com ([211.150.99.135]:48414 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbdI1DSy (ORCPT ); Wed, 27 Sep 2017 23:18:54 -0400 X-263anti-spam: KSV:0;BIG:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ADDR-CHECKED4: 1 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ANTISPAM-LEVEL: 2 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: tglx@linutronix.de X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <59CC6A16.9030201@rock-chips.com> Date: Thu, 28 Sep 2017 11:18:46 +0800 From: jeffy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: Thomas Gleixner CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name References: <20170927122816.18931-1-jeffy.chen@rock-chips.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, Thanks for your review. On 09/27/2017 09:29 PM, Thomas Gleixner wrote: > 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 ..... ok, i'll add that to commit msg. > >> + 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. that is better, will do it in next version :) > > Thanks, > > tglx > > > >