Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp174215ybi; Tue, 2 Jul 2019 18:31:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPl2aEgxFzIY21PHj3OgDrx5wmHlA3kzhTYWeEZtOwwyi9GFGGGwbyYb6FXfw0H2u8zm8C X-Received: by 2002:a63:5b52:: with SMTP id l18mr5583742pgm.21.1562117512053; Tue, 02 Jul 2019 18:31:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562117512; cv=none; d=google.com; s=arc-20160816; b=kC5Pf9X9Eh6MGTxJZJYbAiU047TkFCI5sCY3YGV+hGxFYWAyGOL/bYv1y8axxwu9fe 6Dq3rU0KvOb7R3i3BOSos17tSxKA5Da5+M80cpnywcu3ADMb/EFj99mOyodnjtCo5mIb SxvI7dQOxp3RuiZ8Zg0vV9Z9x4qhG82Z75BtIr7TtzWrKQuGLo22moDaayLzqBYjAvzi Uh9lh8yXfoGHHktVOrNWe6J1IpeKVzvVMUWTp2mI+KBCTnsPmQEsCXx8gwD4j5JYBprH XY5SmG67Ijbh5+bHO5ZWzi/DuLJbP3qQ7U1o536+C4NyH9dhGINcX5rJ8Wyl0e63K9vl YMLQ== 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=qHM4efiqeqLTB+O1cjS0SyEdQyYNocLkrfwOZzdIgpk=; b=YclYjhGeFHZLbFXhkmRHNTjTa5E2fOXQCs5gnhkk7dJfO0QT+AGpWty7vOgWiZaXGb SPv0sJw1jnLSLOJe++f5BWydFEru4D8hPvAf/G3vB+NzDcB6X4BRLZqf77+v+7sys1UV XFBDvtn1AKR2ByuMZmxnYZfF7DfM6venhnycXftQRdK7qEvLT7ZExBgvk5lJME0YmGXo 71Nh6JFIYj1vx31SLL4084eDbqwgjgwsy4Wod/hq3a9sUnnFYyHHQFIbJbft75K+U7TL 4zazhL9N4G06GyvWcNuCG8OYa0GjYd+KNqLI/5Z2xsy3D360snK418Xeu7M8vu3kjoGs e4CA== 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 cb13si461963plb.325.2019.07.02.18.31.36; Tue, 02 Jul 2019 18:31:52 -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 S1727239AbfGCB3M (ORCPT + 99 others); Tue, 2 Jul 2019 21:29:12 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8687 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726652AbfGCB3M (ORCPT ); Tue, 2 Jul 2019 21:29:12 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2D9FCF20B30474FBDB7F; Wed, 3 Jul 2019 09:29:10 +0800 (CST) Received: from [127.0.0.1] (10.184.225.177) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 3 Jul 2019 09:29:03 +0800 Subject: Re: [PATCH] module: add usage links when calling ref_module func To: Jessica Yu CC: , , , , "wangxiaogang (F)" , "Zhoukang (A)" , Mingfangsen References: <8d7aa8b1-73a2-db7a-82c8-06917eddf235@huawei.com> <20190701135556.GA25484@linux-8ccs> From: Zhiqiang Liu Message-ID: <4473a66b-4aee-1d22-aec8-9d6bceb5b303@huawei.com> Date: Wed, 3 Jul 2019 09:28:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190701135556.GA25484@linux-8ccs> Content-Type: text/plain; charset="gb18030" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.184.225.177] 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/7/1 21:55, Jessica Yu wrote: > +++ Zhiqiang Liu [28/06/19 20:32 +0800]: >> From: Zhiqiang Liu >> >> Problem: Users can call ref_module func in their modules to construct >> relationships with other modules. However, the holders >> '/sys/module//holders' of the target module donot include >> the users` module. So lsmod command misses detailed info of 'Used by'. >> >> Here, we will add usage link of a to b's holder_dir. >> >> Fixes: 9bea7f239 ("module: fix bne2 "gave up waiting for init of module libcrc32c") > > I think we can drop this tag; it doesn't fix a bug specifically > introduced by that particular commit. > Thanks for your reply. I will remove the Fixes tag in v2 patch. >> Signed-off-by: Zhiqiang Liu >> --- >> kernel/module.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/kernel/module.c b/kernel/module.c >> index 80c7c09584cf..11c6aff37b1f 100644 >> --- a/kernel/module.c >> +++ b/kernel/module.c >> @@ -871,6 +871,11 @@ int ref_module(struct module *a, struct module *b) >> ?0?2?0?2?0?2?0?2?0?2?0?2?0?2 module_put(b); >> ?0?2?0?2?0?2?0?2?0?2?0?2?0?2 return err; >> ?0?2?0?2?0?2?0?2} >> + >> +?0?2?0?2?0?2 err = sysfs_create_link(b->holders_dir, &a->mkobj.kobj, a->name); >> +?0?2?0?2?0?2 if (err) >> +?0?2?0?2?0?2?0?2?0?2?0?2?0?2 return err; > > We need to fix the error handling here - the module_use struct > allocated in the call to add_module_usage() needs to be freed (you > could just modify add_module_usage() to return the use pointer so that > it's easier to free from within ref_module()), module_put() needs to > be called, and the use struct should be removed from its respective > lists (see module_unload_free()). > Thanks again for your advice. We will modify add_module_usage func to return the use pointer as your suggestion. In the error handling, We will call module_put() and call list_del() to remove the use. > Thanks, > > Jessica > > > . >