From nobody Sat Apr 11 12:14:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 018DEECAAD4 for ; Thu, 1 Sep 2022 02:27:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbiIAC1k (ORCPT ); Wed, 31 Aug 2022 22:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbiIAC1h (ORCPT ); Wed, 31 Aug 2022 22:27:37 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AB2136B04; Wed, 31 Aug 2022 19:27:36 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MJ4dH3lQnznTVF; Thu, 1 Sep 2022 10:25:07 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 10:27:34 +0800 Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 1 Sep 2022 10:27:34 +0800 From: Zhen Lei To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , , CC: Zhen Lei Subject: [PATCH] livepatch: Move error print out of lock protection in klp_enable_patch() Date: Thu, 1 Sep 2022 10:27:06 +0800 Message-ID: <20220901022706.813-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The patch->mod is not a protected object of mutex_lock(&klp_mutex). Since it's in the error handling branch, it might not be helpful to reduce lock conflicts, but it can reduce some code size. Before: text data bss dec hex filename 10330 464 8 10802 2a32 kernel/livepatch/core.o After: text data bss dec hex filename 10307 464 8 10779 2a1b kernel/livepatch/core.o Signed-off-by: Zhen Lei Acked-by: Joe Lawrence --- kernel/livepatch/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 42f7e716d56bf72..cb7abc821a50584 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1041,9 +1041,9 @@ int klp_enable_patch(struct klp_patch *patch) mutex_lock(&klp_mutex); =20 if (!klp_is_patch_compatible(patch)) { + mutex_unlock(&klp_mutex); pr_err("Livepatch patch (%s) is not compatible with the already installe= d livepatches.\n", patch->mod->name); - mutex_unlock(&klp_mutex); return -EINVAL; } =20 --=20 2.25.1