From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07CBBC33CB1 for ; Fri, 17 Jan 2020 15:04:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCFFA20842 for ; Fri, 17 Jan 2020 15:04:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbgAQPEe (ORCPT ); Fri, 17 Jan 2020 10:04:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:46284 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729146AbgAQPEC (ORCPT ); Fri, 17 Jan 2020 10:04:02 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 31657BBB3; Fri, 17 Jan 2020 15:04:01 +0000 (UTC) From: Petr Mladek To: Jiri Kosina , Josh Poimboeuf , Miroslav Benes Cc: Joe Lawrence , Kamalesh Babulal , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek Subject: [POC 16/23] livepatch: Add patch into the global list early Date: Fri, 17 Jan 2020 16:03:16 +0100 Message-Id: <20200117150323.21801-17-pmladek@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200117150323.21801-1-pmladek@suse.com> References: <20200117150323.21801-1-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The objects for livepatched modules need to be loaded before the livepatch gets enabled. klp_add_module() has to find the patch. The code is easier when the being-enabled patch can be found in the global list. Fortunately, there is no problem to add patch into the list already in the early init. klp_free_patch_start() will remove it in case of any later error. Signed-off-by: Petr Mladek --- kernel/livepatch/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 688ad81def14..06676ec63ba7 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -852,6 +852,7 @@ static int klp_init_object_early(struct klp_patch *patch, static int klp_init_patch_early(struct klp_patch *patch) { struct klp_object *obj = patch->obj; + int ret; /* Main patch module is always for vmlinux */ if (obj->name) @@ -865,7 +866,11 @@ static int klp_init_patch_early(struct klp_patch *patch) INIT_WORK(&patch->free_work, klp_free_patch_work_fn); init_completion(&patch->finish); - return klp_init_object_early(patch, obj); + ret = klp_init_object_early(patch, obj); + if (!ret) + list_add_tail(&patch->list, &klp_patches); + + return ret; } static int klp_init_patch(struct klp_patch *patch) @@ -889,8 +894,6 @@ static int klp_init_patch(struct klp_patch *patch) return ret; } - list_add_tail(&patch->list, &klp_patches); - return 0; } -- 2.16.4