Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753396AbcKUICQ (ORCPT ); Mon, 21 Nov 2016 03:02:16 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35742 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752911AbcKUICO (ORCPT ); Mon, 21 Nov 2016 03:02:14 -0500 Subject: Re: [PATCH] stm class: Add a missing call to put_device To: Alexander Shishkin , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20161119182241.9030-1-lambert.quentin@gmail.com> <87k2bxe194.fsf@ashishki-desk.ger.corp.intel.com> From: Quentin Lambert Message-ID: <336d516d-a256-fd70-1c08-8c42880a2821@gmail.com> Date: Mon, 21 Nov 2016 08:58:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87k2bxe194.fsf@ashishki-desk.ger.corp.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1241 Lines: 43 On 11/21/2016 08:32 AM, Alexander Shishkin wrote: > Quentin Lambert writes: > >> Most error branches following the call to class_find_device contain >> a call to put_device. This patch add calls to put_device where >> they are missing. >> >> This issue was found with Hector. >> >> Signed-off-by: Quentin Lambert >> >> --- >> drivers/hwtracing/stm/core.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> --- a/drivers/hwtracing/stm/core.c >> +++ b/drivers/hwtracing/stm/core.c >> @@ -368,8 +368,10 @@ static int stm_char_open(struct inode *i >> return -ENODEV; >> >> stmf = kzalloc(sizeof(*stmf), GFP_KERNEL); >> - if (!stmf) >> + if (!stmf) { >> + put_device(dev); >> return -ENOMEM; >> + } > There is a goto label at the bottom of this function which is supposed > to deal with this. See the fix that we already have [1] for this issue. > > [1] https://git.kernel.org/cgit/linux/kernel/git/ash/stm.git/commit/?h=stm-for-greg-20161118&id=a0ebf519b8a2666438d999c62995618c710573e5 > > Regards, > -- > alex Your fix is better, you are right, I did not use the goto label because of the free. Thanks for your feedback though. Regards, Quentin