Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7377717rwb; Tue, 15 Nov 2022 11:19:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CiMo5gyEW10HmOGT6Yg3JywXoaPkHG2pSecIcxmu5uKcLH3/Gq9PhgGvoMllG6tVZGBCL X-Received: by 2002:a17:906:9c41:b0:78d:ad29:396f with SMTP id fg1-20020a1709069c4100b0078dad29396fmr15270501ejc.165.1668539957361; Tue, 15 Nov 2022 11:19:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668539957; cv=none; d=google.com; s=arc-20160816; b=GX3tbaXMWFz/mvCws+mez0diB0moCjbiqmMmu7m+c7fimL+xJq9IkeerxXl5e/MQkj CyjCRrOtwv/vcEV/MvHKpLa2grPrYaYyDkttGBoFJc/5zBgZS0skG9YM6Hn4UmCvKVe0 BQdzYcRI/mFdUzYzbqtF1CbHNNLtdRGR3jLsbpxsAW0CLRYxemns7kn51WdlKgKeKzKI Gt+sjMGJ35dyGqGQNV1LnSadWPbbRQrV+MJkHpmAW7Ixaj7fapcjBrvc1I1uwQL1opoR WwKGfBJcdrgTjLY8HuRy1wNwMjdcQmhbcxH2u5JXv2LRPi2zt3vArB9P9U/e2qa6qgnH z1Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WO8FJVxCOWsBl/IOuAtatDZ8TXJVgPubAFuKis1Ssu8=; b=kP+PFE4SmFBT4heaDmeUgmbDkh7SaT+GywBFMykp+SgPRhLueT81TSD6IIcFXkxMSp HovvDt0SLCMy8medJ4BQ5bU/MdRRFYH2vVHgvRnI0A9wFtLah1zEhWWjDKkTGTgKAhly 5Zb6RFoxP0JiktFJpfoHpK9K+a4ko3eA7eKxxi+BicvhlAkP6eJlc6S1X2MTVtmVJaNw zR9i/rhJ2gLvndNgO1ep/ZdNrWT84NXPw5Q1wuyoTklwyqmrBdNvlOFKk8Inl0g4CHAL LxQJNsEKkaCjrhWyQRYGGQHhuxIxU0mAyCEyyaRF7IZOjhVIbquBlE7v812/CTr8shcm MZwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z83pzcQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn17-20020a17090794d100b0078cff711da6si14656745ejc.976.2022.11.15.11.18.55; Tue, 15 Nov 2022 11:19:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z83pzcQO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231175AbiKOSsW (ORCPT + 90 others); Tue, 15 Nov 2022 13:48:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231258AbiKOSsT (ORCPT ); Tue, 15 Nov 2022 13:48:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE3C42F00F for ; Tue, 15 Nov 2022 10:48:18 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6DA0A6195B for ; Tue, 15 Nov 2022 18:48:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E733C433D6; Tue, 15 Nov 2022 18:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1668538097; bh=4h2pLemwieK+6X9ajdqA8ftjo1wxmsuup5HG2B6pxco=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=z83pzcQOuZqb2h3fNAbU18Y+hZu25jBrKl096793e+BmmFYSXzL46HyV0yhCzAkri FLhhAx+oUevjwyuD9v/wO0gsUZXaEFyXn+VvALoboJJOjQtukSsVuSjVoRWyt+VuXO 8dKgEPCJqAI9mgl3V3aaKtCHbLfsfYQyFNtxaIxo= Date: Tue, 15 Nov 2022 19:48:15 +0100 From: Greg KH To: Paul Fulghum Cc: Zhengchao Shao , linux-kernel@vger.kernel.org, jirislaby@kernel.org, akpm@linux-foundation.org, weiyongjun1@huawei.com, yuehaibing@huawei.com Subject: Re: [PATCH] tty: synclink_gt: unwind actions in error path of net device open Message-ID: References: <20221114010734.314910-1-shaozhengchao@huawei.com> <2b501d50-6777-a34f-7373-6648ed418794@microgate.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b501d50-6777-a34f-7373-6648ed418794@microgate.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 15, 2022 at 10:21:14AM -0800, Paul Fulghum wrote: > hdlcdev_open() in synclink_gt.c did not fully unwind actions > in the error path. The use of try_module_get()/module_put() is unnecessary, > potentially hazardous and is removed. The synclink_gt driver is already > pinned any point the net device is registered, a requirement for calling > this entry point. > > The call hdlc_open() to init the generic HDLC layer is moved to > after driver level init/checks and proper rollback of previous > actions is added. This is a more sensible ordering as the > most common error paths are at the driver level and the driver > level rollbacks require less processing than > hdlc_open()/hdlc_close(). > > This has been tested with supported hardware. > > Suggested-by: Zhengchao Shao > Signed-off-by: Paul Fulghum > > diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c > index 25e9befdda3a..72b76cdde534 100644 > --- a/drivers/tty/synclink_gt.c > +++ b/drivers/tty/synclink_gt.c > @@ -1433,16 +1433,8 @@ static int hdlcdev_open(struct net_device *dev) > int rc; > unsigned long flags; > > - if (!try_module_get(THIS_MODULE)) > - return -EBUSY; > - > DBGINFO(("%s hdlcdev_open\n", dev->name)); > > - /* generic HDLC layer open processing */ > - rc = hdlc_open(dev); > - if (rc) > - return rc; > - > /* arbitrate between network and tty opens */ > spin_lock_irqsave(&info->netlock, flags); > if (info->port.count != 0 || info->netcount != 0) { > @@ -1461,6 +1453,16 @@ static int hdlcdev_open(struct net_device *dev) > return rc; > } > > + /* generic HDLC layer open processing */ > + rc = hdlc_open(dev); > + if (rc) { > + shutdown(info); > + spin_lock_irqsave(&info->netlock, flags); > + info->netcount = 0; > + spin_unlock_irqrestore(&info->netlock, flags); > + return rc; > + } > + > /* assert RTS and DTR, apply hardware settings */ > info->signals |= SerialSignal_RTS | SerialSignal_DTR; > program_hw(info); > @@ -1506,7 +1508,6 @@ static int hdlcdev_close(struct net_device *dev) > info->netcount=0; > spin_unlock_irqrestore(&info->netlock, flags); > > - module_put(THIS_MODULE); > return 0; > } > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - Your patch is malformed (tabs converted to spaces, linewrapped, etc.) and can not be applied. Please read the file, Documentation/email-clients.txt in order to fix this. - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot