public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] [PATCH] efivars spinlock fix
@ 2001-07-23 14:53 Matt_Domsch
  0 siblings, 0 replies; only message in thread
From: Matt_Domsch @ 2001-07-23 14:53 UTC (permalink / raw)
  To: linux-ia64

The patch below fixes a couple potential failures in the efivars module.
First, it was calling kmalloc, which could sleep, while holding a spinlock.
Second, it would fail to free allocated memory if copy_from_user() failed.

David, please apply.

Thanks,
Matt

--
Matt Domsch
Sr. Software Engineer
Dell Linux Solutions
www.dell.com/linux
#2 Linux Server provider with 17% in the US and 14% Worldwide (IDC)!
#3 Unix provider with 18% in the US (Dataquest)!


--- linux/arch/ia64/kernel/efivars.c.orig	Wed Jul 18 22:09:12 2001
+++ linux/arch/ia64/kernel/efivars.c	Wed Jul 18 22:13:36 2001
@@ -276,21 +276,20 @@
 	if (!capable(CAP_SYS_ADMIN))
 		return -EACCES;
 
-	spin_lock(&efivars_lock);
 	MOD_INC_USE_COUNT;
 
 	var_data = kmalloc(size, GFP_KERNEL);
 	if (!var_data) {
 		MOD_DEC_USE_COUNT;
-		spin_unlock(&efivars_lock);
 		return -ENOMEM;
 	}
 	if (copy_from_user(var_data, buffer, size)) {
 		MOD_DEC_USE_COUNT;
-		spin_unlock(&efivars_lock);
+		kfree(var_data);
 		return -EFAULT;
 	}
 
+	spin_lock(&efivars_lock);
 
 	/* Since the data ptr we've currently got is probably for
 	   a different variable find the right variable.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-07-23 14:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-23 14:53 [Linux-ia64] [PATCH] efivars spinlock fix Matt_Domsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox