Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MT6XS-0008As-0F for mharc-grub-devel@gnu.org; Tue, 21 Jul 2009 00:01:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MT6XP-0008A5-Ra for grub-devel@gnu.org; Tue, 21 Jul 2009 00:01:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MT6XL-00084j-AC for grub-devel@gnu.org; Tue, 21 Jul 2009 00:01:11 -0400 Received: from [199.232.76.173] (port=44996 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MT6XL-00084g-86 for grub-devel@gnu.org; Tue, 21 Jul 2009 00:01:07 -0400 Received: from mail-yx0-f172.google.com ([209.85.210.172]:52995) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MT6XK-0007jb-QA for grub-devel@gnu.org; Tue, 21 Jul 2009 00:01:06 -0400 Received: by yxe2 with SMTP id 2so5027104yxe.14 for ; Mon, 20 Jul 2009 21:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:message-id :from:to:content-type:content-transfer-encoding:mime-version:subject :date:x-mailer; bh=P9+/B0yE1r+b8CKTEFJVEKsTUAfqtN8gT3oiv3+xzio=; b=JRwc+bYE9/0M1tqxgl1tn9NGAly41/liwE25zaBB20ps3XY25xezUDfgb1L3cqrgHj yNcgQpFrOau7gyxUy3/zyXouJ5ripJP9g4bBhq2jRQPpUDxEVSBYZqyGMN4s0hFQcens TKdVqA7JF9ZGtjvN8C6QnTrAjX4vrFLQCIrDE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=HE1WsuQlsUfHEj82kzcyeBcHMHRmVhHlPrFssnxOz/EUuLQbKwpske2urQe2nFevFX EIOBXxFmLGzyywv3nh8jO+YmUqk7h2e+T99Fmj736K4NpWmUIJGqWGGTKr3BWRfuNhkq jRvOG0FK8YOi+KVxca94l4SHYxbmmlTqKAtWQ= Received: by 10.90.33.20 with SMTP id g20mr1120566agg.58.1248148865723; Mon, 20 Jul 2009 21:01:05 -0700 (PDT) Received: from mail.definitelynotsafe.com (cpe-66-75-249-204.san.res.rr.com [66.75.249.204]) by mx.google.com with ESMTPS id 7sm2963819agb.41.2009.07.20.21.01.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 20 Jul 2009 21:01:04 -0700 (PDT) Sender: Joe Auricchio Received: from [10.24.0.125] (unknown [10.24.0.1]) (Authenticated sender: jauricch) by mail.definitelynotsafe.com (Postfix) with ESMTPSA id EEE03171B4 for ; Mon, 20 Jul 2009 21:00:23 -0700 (PDT) Message-Id: <80B79CE8-EF71-4B5E-BFC8-477C17756D41@gmail.com> From: Joe Auricchio To: grub-devel@gnu.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Date: Mon, 20 Jul 2009 21:00:57 -0700 X-Mailer: Apple Mail (2.935.3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] Call a module's init function only after the module is successfully added X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2009 04:01:12 -0000 Hi, * kern/dl.c (grub_dl_load_core): Call grub_dl_call_init only after successful grub_dl_add With this patch the module's init function will no longer be called: - if the module is already loaded - if malloc fails in grub_dl_add - before the module is added to grub_dl_head The first two are errors and cause the load to abort. The module shouldn't try to init if it's only going to abort. I don't know much about grub_dl_head, so I don't know if #3 could have caused problems. -joe -=-=-=-=-=-=-=-=-=-=-=-=- --- a/grub2/kern/dl.c 2009-07-07 16:58:01.000000000 -0700 +++ b/grub2/kern/dl.c 2009-07-16 13:57:18.000000000 -0700 @@ -558,16 +558,17 @@ grub_dl_flush_cache (mod); grub_dprintf ("modules", "module name: %s\n", mod->name); grub_dprintf ("modules", "init function: %p\n", mod->init); - grub_dl_call_init (mod); if (grub_dl_add (mod)) { grub_dl_unload (mod); return 0; } + grub_dl_call_init (mod); + return mod; } /* Load a module from the file FILENAME. */