Commit 55e858c8 authored by John Kacur's avatar John Kacur Committed by Thomas Gleixner

agp: Remove the BKL from agp_open

- Remove the BKL from agp_open
- Perform a few clean-ups.

Analysis:
---------
int minor is local to the function.

The following are protected by agp_fe.agp_mutex
struct agp_file_private *priv;
struct agp_client *client;

Call-outs:

kzalloc should be safe to call under the mutex_lock

agp_find_client_by_pid:
	- agp_mmap calls that under agp_fe.agp_mutex which we hold in agp_open
	- agpioc_reserve_wrap calls it without any locking what-so-ever.
		- Is that an error? Or is that okay because it has pid that is
		  a unique handle?

agp_insert_file_private:
	- This function only manipulates struct agp_file_private, once again
	  while agp_fe.agp_mutex is held
Signed-off-by: default avatarJohn Kacur <jkacur@redhat.com>
Acked-by: default avatarDavid Airlie <airlied@linux.ie>
LKML-Reference: <alpine.LFD.2.00.0910112216060.12574@localhost.localdomain>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent f96d3015
...@@ -676,25 +676,25 @@ static int agp_open(struct inode *inode, struct file *file) ...@@ -676,25 +676,25 @@ static int agp_open(struct inode *inode, struct file *file)
int minor = iminor(inode); int minor = iminor(inode);
struct agp_file_private *priv; struct agp_file_private *priv;
struct agp_client *client; struct agp_client *client;
int rc = -ENXIO;
lock_kernel();
mutex_lock(&(agp_fe.agp_mutex));
if (minor != AGPGART_MINOR) if (minor != AGPGART_MINOR)
goto err_out; return -ENXIO;
mutex_lock(&(agp_fe.agp_mutex));
priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL); priv = kzalloc(sizeof(struct agp_file_private), GFP_KERNEL);
if (priv == NULL) if (priv == NULL) {
goto err_out_nomem; mutex_unlock(&(agp_fe.agp_mutex));
return -ENOMEM;
}
set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags); set_bit(AGP_FF_ALLOW_CLIENT, &priv->access_flags);
priv->my_pid = current->pid; priv->my_pid = current->pid;
if (capable(CAP_SYS_RAWIO)) { if (capable(CAP_SYS_RAWIO))
/* Root priv, can be controller */ /* Root priv, can be controller */
set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags); set_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags);
}
client = agp_find_client_by_pid(current->pid); client = agp_find_client_by_pid(current->pid);
if (client != NULL) { if (client != NULL) {
...@@ -704,16 +704,10 @@ static int agp_open(struct inode *inode, struct file *file) ...@@ -704,16 +704,10 @@ static int agp_open(struct inode *inode, struct file *file)
file->private_data = (void *) priv; file->private_data = (void *) priv;
agp_insert_file_private(priv); agp_insert_file_private(priv);
DBG("private=%p, client=%p", priv, client); DBG("private=%p, client=%p", priv, client);
mutex_unlock(&(agp_fe.agp_mutex));
unlock_kernel();
return 0;
err_out_nomem:
rc = -ENOMEM;
err_out:
mutex_unlock(&(agp_fe.agp_mutex)); mutex_unlock(&(agp_fe.agp_mutex));
unlock_kernel();
return rc; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment