From: Takashi Iwai Subject: Re: [PATCH 1/4] ASoC: mc13783: Fix of_node_put() call with uninitialized object Date: Tue, 07 Oct 2014 19:39:03 +0200 Message-ID: References: <1412698794-25536-1-git-send-email-tiwai@suse.de> <1412698794-25536-2-git-send-email-tiwai@suse.de> <20141007170938.GM4609@sirena.org.uk> <20141007172337.GR4609@sirena.org.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9A1E926059E for ; Tue, 7 Oct 2014 19:39:03 +0200 (CEST) In-Reply-To: <20141007172337.GR4609@sirena.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Tue, 7 Oct 2014 18:23:37 +0100, Mark Brown wrote: > > On Tue, Oct 07, 2014 at 07:17:08PM +0200, Takashi Iwai wrote: > > Mark Brown wrote: > > > > On Tue, Oct 07, 2014 at 06:19:51PM +0200, Takashi Iwai wrote: > > > > > - struct device_node *np; > > > > + struct device_node *np = NULL; > > > > No, unconditional initialisations like this are worse than the problem > > > they're trying to fix. > > > Which problem they're trying to fix...? > > Shutting up warnings - because they just brute forcing they mean that if > there's anything else we've missed the compiler won't be able to tell us > about it. > > > Initializing with NULL for the of_node_put() at error path is a > > standard idiom. An alternative fix would be to add "if (!pdata)" > > before of_node_put(np). But this isn't really intuitive, either (and > > even more error-prone, IMO). > > Well, in this case I'd just move the of_node_put() into the existing > check for pdata since we don't ever reference np outside of that anyway. Yeah, that's an option, too, but it'd make the code less readable. So I chose the straightforward way. Takashi