Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1095233ybx; Thu, 31 Oct 2019 05:40:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmMu+HHuQGLcnJua1WXy5ew1ug+j35N57l4ABH8l4RNtXVMnGR9nk+H7+cSDUqAxVHSdQA X-Received: by 2002:a17:906:2cd4:: with SMTP id r20mr3577094ejr.307.1572525649784; Thu, 31 Oct 2019 05:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572525649; cv=none; d=google.com; s=arc-20160816; b=Xk1DLczyX/1yfTg55zjaMPFi1vOzP6K/n2AIdz8KnzhCWuPAif+MktuziZDJEUdd77 WhkIGdes5YuZSiIwAjv8elG51HgIcRYJMkrBYQcN3EBBg9N5BQFTZ/+ylU14ZV5m7vWH hFfM7xDhgfW78sBetIvMiMTi1jrv+90tZoYyYVP7WFwglBRMzioRhL9Mzcdgsm9YLLDR uP857AXNTcut++63HcoXzsLywWu9wra2pnrv7g/oV3ljhl1yYWR4IlQumEYogTBUxwHb XDgI7YkPVwOC9nJo7dvMhXcx1sL41kyRl4iGNSZHoy8eft/FFsxucz8ArP9Fou1H7Phw 6fxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=OipbuIUITAqB+to6XUs7SZdZnfky7Pz2APG/nkBB8ak=; b=bnlVsdrgHmP4npmaGdose35ODd8efZXr1JvvMbAfGbU1wGLItntxYA3KWTV2F36gFk Nf7EQaZT0/miTaYDk9KqXyweV/U4XfwJ6o4A+bZDdyRadMT9SdVaQxg/xotFBjcXXOJO XL/VZpYimpF9Xw0UyiqG/9NT6EggZqc0nOUen8sJfBEnWv6NLXZ7l/2u+GKPHqgd5QYh +ky4D6clwUkft6O+u640lz+rH+STsmGID+/eyZDJN07q0w9kcgO9hFok6GXNeJmZk+bt HRuxTCD6Jdq3eRYrOVJSrqx24zKBzaBvynjbHhuhb9Ffvj2nbquUU+IIbvx1uQ6WqBlF 0C/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si3248003ejw.75.2019.10.31.05.40.25; Thu, 31 Oct 2019 05:40:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726944AbfJaMio (ORCPT + 99 others); Thu, 31 Oct 2019 08:38:44 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5238 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726506AbfJaMim (ORCPT ); Thu, 31 Oct 2019 08:38:42 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C50CC42C892F09C4CA5E; Thu, 31 Oct 2019 20:38:40 +0800 (CST) Received: from [127.0.0.1] (10.67.102.197) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Thu, 31 Oct 2019 20:38:38 +0800 Subject: Re: [PATCH] tty:n_gsm.c: destroy port by tty_port_destroy() To: Jiri Slaby , CC: References: <1569317156-45850-1-git-send-email-nixiaoming@huawei.com> <1fd7d2eb-7497-254b-b40f-84bc4114f8a3@suse.com> From: Xiaoming Ni Message-ID: <9d515be6-5430-7ca2-24e8-a8c3798beec9@huawei.com> Date: Thu, 31 Oct 2019 20:38:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: <1fd7d2eb-7497-254b-b40f-84bc4114f8a3@suse.com> Content-Type: text/plain; charset="iso-8859-2"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.197] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/10/31 18:11, Jiri Slaby wrote: > On 24. 09. 19, 11:25, Xiaoming Ni wrote: >> According to the comment of tty_port_destroy(): >> When a port was initialized using tty_port_init, one has to destroy >> the port by tty_port_destroy(); > > It continues with a part saying: > Either indirectly by using tty_port refcounting > (tty_port_put) or directly if refcounting is not used. > >> tty_port_init() is called in gsm_dlci_alloc() >> so tty_port_destroy() needs to be called in gsm_dlci_free() >> >> Signed-off-by: Xiaoming Ni >> --- >> drivers/tty/n_gsm.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c >> index 36a3eb4..3f5bcc9 100644 >> --- a/drivers/tty/n_gsm.c >> +++ b/drivers/tty/n_gsm.c >> @@ -1681,6 +1681,7 @@ static void gsm_dlci_free(struct tty_port *port) >> >> del_timer_sync(&dlci->t1); >> dlci->gsm->dlci[dlci->addr] = NULL; >> + tty_port_destroy(&dlci->port); > > This is wrong. gsm_dlci_free is tty_port_operations->destruct, i.e. > n_gsm uses tty_port refcounting and tty_port_destroy was called on this > port in tty_port_destructor already. > > Greg, please revert. > > thanks, > Function call flow tty_port_put ===> tty_port_destructor ??????? ===> tty_port_destroy ?????????? Port->ops->destruct(port); ?????????????? ===> .destruct = gsm_dlci_free Thank you for your correction, I am wrong. thanks