From patchwork Mon Jul 19 14:52:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 480575 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 A46D0C64E61 for ; Mon, 19 Jul 2021 16:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 874136127C for ; Mon, 19 Jul 2021 16:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239053AbhGSPhn (ORCPT ); Mon, 19 Jul 2021 11:37:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:59806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347323AbhGSPfH (ORCPT ); Mon, 19 Jul 2021 11:35:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C30661457; Mon, 19 Jul 2021 16:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711129; bh=M6UPGWBZua8uVdgs9rcujGlz0P9agDbxYeYR0nvMEy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lvWH8WwrjQXUKlezhdg6dtTzjNmnNqi769eKm9a22wHk9EseTtb+8Me1TPJsSSXIs /Y2LfQivl4EkOuxj4qD2xKdih71YJYqClg5kfK33KAUqsYZ4AW5FOKl6bJkNUQC4J8 q+rH5L1419IufdJxdnbkLm++V0MIZX3WQXhx/ptY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Mladek , Miroslav Benes , Jon Mediero , Jessica Yu , Sasha Levin Subject: [PATCH 5.13 205/351] module: correctly exit module_kallsyms_on_each_symbol when fn() != 0 Date: Mon, 19 Jul 2021 16:52:31 +0200 Message-Id: <20210719144951.750512944@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144944.537151528@linuxfoundation.org> References: <20210719144944.537151528@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jon Mediero [ Upstream commit 2c0f0f3639562d6e38ee9705303c6457c4936eac ] Commit 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol") replaced the return inside the nested loop with a break, changing the semantics of the function: the break only exits the innermost loop, so the code continues iterating the symbols of the next module instead of exiting. Fixes: 013c1667cf78 ("kallsyms: refactor {,module_}kallsyms_on_each_symbol") Reviewed-by: Petr Mladek Reviewed-by: Miroslav Benes Signed-off-by: Jon Mediero Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index 927d46cb8eb9..0b850188419a 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -4425,9 +4425,10 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, ret = fn(data, kallsyms_symbol_name(kallsyms, i), mod, kallsyms_symbol_value(sym)); if (ret != 0) - break; + goto out; } } +out: mutex_unlock(&module_mutex); return ret; }