From patchwork Thu Nov 3 01:17:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Chang" X-Patchwork-Id: 13029380 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C90E0C433FE for ; Thu, 3 Nov 2022 01:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WQBJvv+eeULEXYyvAe0YUZKgfPGzorsZTvW9tjcGkbg=; b=vW/DFo0kPDyhK9 GgbZnlUHJCRNTF3jwq8M8l2TxG+H0EfdMMTTv9uzGlXJFfPyOHgXqxawNmojCdmUOiN1PMO0hEv+i 4hDkJztbNFLmWYTrTJoIsvIj7zH78oF6MMMIY7qua8W1ZMwNx8GwXWfdoAoQqiqI+RWKvTS7q9PpA 9rjWrmkF+xMXNMqyWQ20zQYskSzojs3ogOPjCXJbKWH0OAzkblYXGNC4Tv4jLheCLNCWusoAApF9v FPRz7eCTDU8zgjCaL3aYxVbyN0lNhnbL8BHut2P5WvKKXvXNgz09wNlNPjsAEEgdObfBfZIKCWeRJ BaB9fPmZydwAWWcPjtHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqOuP-00FVKU-1K; Thu, 03 Nov 2022 01:20:41 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqOuM-00FVH5-6C for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2022 01:20:39 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N2m8G2jT7zJnQL; Thu, 3 Nov 2022 09:17:34 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 09:20:28 +0800 From: Liao Chang To: , , , , , , CC: , Subject: [PATCH] ARM: module: Reclaim the unwind list of module on kmalloc failed Date: Thu, 3 Nov 2022 09:17:13 +0800 Message-ID: <20221103011713.138974-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221102_182038_411658_F6135C46 X-CRM114-Status: UNSURE ( 7.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When unwind table allocation failed, it needs to reclaim the unwind list of module to avoid potential NULL pointer exception and memory leakage. Fixes: b6f21d14f1ac ("ARM: 9204/2: module: Add all unwind tables when load module") Signed-off-by: Liao Chang Cc: Chen Zhongjin Reviewed-by: Chen Zhongjin Reviewed-by: Linus Walleij --- arch/arm/kernel/module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index d59c36dc0494..cc637dcdcb10 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -485,6 +485,10 @@ int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs, s->sh_size, txt_sec->sh_addr, txt_sec->sh_size); + if (!table) { + module_arch_cleanup(mod); + return -ENOMEM; + } list_add(&table->mod_list, unwind_list);