From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbbKYKeW (ORCPT ); Wed, 25 Nov 2015 05:34:22 -0500 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:54740 "EHLO e28smtp05.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750796AbbKYKeT (ORCPT ); Wed, 25 Nov 2015 05:34:19 -0500 X-Helo: d28dlp01.in.ibm.com X-MailFrom: xinhui@linux.vnet.ibm.com X-RcptTo: stable@vger.kernel.org Subject: Re: [PATCH] TTY: n_gsm, fix false positive WARN_ON To: Jiri Slaby , Greg Kroah-Hartman References: <1448384067-27300-1-git-send-email-jslaby@suse.cz> <56555613.1040502@linux.vnet.ibm.com> <565585B9.4040706@suse.cz> Cc: dvyukov@google.com, linux-kernel@vger.kernel.org, Alan Cox , stable From: xinhui Message-ID: <56558E48.3020604@linux.vnet.ibm.com> Date: Wed, 25 Nov 2015 18:32:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <565585B9.4040706@suse.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15112510-0017-0000-0000-00000895D8D9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, Jiri On 2015/11/25 17:56, Jiri Slaby wrote: > Hi, > > On 11/25/2015, 07:32 AM, xinhui wrote: >> This warning should blame on commit 5a640967 ("tty/n_gsm.c: fix a >> memory leak in gsmld_open()"). > > Oh, yes, I messed up the "Fixes" line then. It should write: > Fixes: 5a640967 ("tty/n_gsm.c: fix a memory leak in gsmld_open()") > that's Okay. :) >> I have one confusion. As there is field gsm->num to store the index of >> gsm_mux[]. so in gsm_cleanup_mux(), why we still use for-loop to find >> this mux? >> >> In error handle path, for example, the call trace in this patch, as we >> failed to activate it and the >> gsm->num is invalid(and the value is 0). we can just modify the codes >> like below: >> >> if(gsm_mux[gsm->num] == gsm) >> ....other work >> else >> return; >> >> I think it would work, and the logic is correct. Or I just miss >> something important? > > Yup, it looks like a cleanup. Could you prepare a separate patch for that? > yes, I will do that :) > Something like this: > /* open failed before registering => nothing to do */ > if (gsm_mux[gsm->num] != gsm) > return; > spin_lock(&gsm_mux_lock); > gsm_mux[gsm->num] = NULL; > spin_unlock(&gsm_mux_lock); > looks pretty good, thanks. > thanks, > thanks xinhui