From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MTSK2-0000PM-Dy for mharc-grub-devel@gnu.org; Tue, 21 Jul 2009 23:16:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTSK0-0000Oz-K7 for grub-devel@gnu.org; Tue, 21 Jul 2009 23:16:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTSJv-0000On-7H for grub-devel@gnu.org; Tue, 21 Jul 2009 23:16:47 -0400 Received: from [199.232.76.173] (port=43963 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTSJu-0000Ok-W5 for grub-devel@gnu.org; Tue, 21 Jul 2009 23:16:43 -0400 Received: from c60.cesmail.net ([216.154.195.49]:37712) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MTSJu-0007h0-Hz for grub-devel@gnu.org; Tue, 21 Jul 2009 23:16:42 -0400 Received: from unknown (HELO smtprelay1.cesmail.net) ([192.168.1.111]) by c60.cesmail.net with ESMTP; 21 Jul 2009 23:16:40 -0400 Received: from mj.roinet.com (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay1.cesmail.net (Postfix) with ESMTPSA id 281F834C69 for ; Tue, 21 Jul 2009 23:16:39 -0400 (EDT) To: grub-devel@gnu.org From: Pavel Roskin Date: Tue, 21 Jul 2009 23:16:38 -0400 Message-ID: <20090722031638.6348.79007.stgit@mj.roinet.com> User-Agent: StGit/0.15-rc1-9-gd8846 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH 1/4] Handle errors in rmmod 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: Wed, 22 Jul 2009 03:16:48 -0000 ChangeLog: * commands/minicmd.c (grub_mini_cmd_rmmod): Check the result of grub_dl_unload(), but not of grub_dl_unref(). On failure, restore reference count and report error. --- commands/minicmd.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/minicmd.c b/commands/minicmd.c index b314388..1f5abae 100644 --- a/commands/minicmd.c +++ b/commands/minicmd.c @@ -288,8 +288,12 @@ grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)), if (! mod) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module"); - if (grub_dl_unref (mod) <= 0) - grub_dl_unload (mod); + grub_dl_unref (mod); + if (grub_dl_unload (mod) == 0) + { + grub_dl_ref (mod); + return grub_error (GRUB_ERR_BAD_MODULE, "`%s' is in use", mod->name); + } return 0; }