Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MTLYA-0003d2-Gq for mharc-grub-devel@gnu.org; Tue, 21 Jul 2009 16:02:58 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTLY8-0003cf-F9 for grub-devel@gnu.org; Tue, 21 Jul 2009 16:02:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTLY4-0003cH-Rx for grub-devel@gnu.org; Tue, 21 Jul 2009 16:02:56 -0400 Received: from [199.232.76.173] (port=35246 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTLY4-0003c9-MP for grub-devel@gnu.org; Tue, 21 Jul 2009 16:02:52 -0400 Received: from c60.cesmail.net ([216.154.195.49]:16511) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MTLY3-0005rV-VL for grub-devel@gnu.org; Tue, 21 Jul 2009 16:02:52 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 21 Jul 2009 16:02:49 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id 03E5F34C6A for ; Tue, 21 Jul 2009 16:13:14 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: <80B79CE8-EF71-4B5E-BFC8-477C17756D41@gmail.com> References: <80B79CE8-EF71-4B5E-BFC8-477C17756D41@gmail.com> Content-Type: text/plain Date: Tue, 21 Jul 2009 16:02:48 -0400 Message-Id: <1248206568.3327.18.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [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 20:02:56 -0000 On Mon, 2009-07-20 at 21:00 -0700, Joe Auricchio wrote: > 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. I have no objections. By the way, kern/dl.c have some unused functions (grub_dl_unload_all). Also, it looks like the memory for the module information (grub_dl_t) is allocated twice - first in grub_dl_load_core(), then in grub_dl_add() as part of grub_dl_list_t. grub_dl_load() can return either memory from the list that shouldn't be freed by the caller, or the result of grub_dl_load_file(), which is allocated and is not referenced anywhere. -- Regards, Pavel Roskin