From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753415AbdI0NaJ (ORCPT ); Wed, 27 Sep 2017 09:30:09 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:53009 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753123AbdI0NaH (ORCPT ); Wed, 27 Sep 2017 09:30:07 -0400 Date: Wed, 27 Sep 2017 15:29:57 +0200 (CEST) From: Thomas Gleixner To: Jeffy Chen cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] irq/generic-chip: Fix memory leak of domain->name In-Reply-To: <20170927122816.18931-1-jeffy.chen@rock-chips.com> Message-ID: References: <20170927122816.18931-1-jeffy.chen@rock-chips.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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