From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753866AbdIDPej (ORCPT ); Mon, 4 Sep 2017 11:34:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:36753 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753751AbdIDPei (ORCPT ); Mon, 4 Sep 2017 11:34:38 -0400 Date: Mon, 04 Sep 2017 17:34:36 +0200 Message-ID: From: Takashi Iwai To: Wang YanQing Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe In-Reply-To: <20170904151709.GA19742@udknight> References: <20170904151709.GA19742@udknight> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.2 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 04 Sep 2017 17:17:09 +0200, Wang YanQing wrote: > > When hda_codec_driver_probe meet error and return failure, we need > to free resource with patch_ops.free, or we will get resource leak. > > Signed-off-by: Wang YanQing > --- > Changes v1-v2: > 1: Fix calling patch_ops.free after module_put, reported by Takashi Iwai. > > Hi! Takashi Iwai > Because the only one calling site of patch_ops.free is in > hda_codec_driver_remove, and if hda_codec_driver_probe return > failure, we will no chance to call the hda_codec_driver_remove, > so I think we don't need to care below case: > "Or, for safety, we may put an internal flag to indicate that the codec > free got already called, and check it at before calling > patch_ops.free, too." Fair enough, applied now. I found patch_ca0132.c still misses the free at the error path in its probe function, so I'll fix it. thanks, Takashi