Skip to contentSkip to conversation

Eliminate recursive mutex in compat fb ioctl path

PATCH In review Keith Packard 2 participants 2 messages Nov 3, 2008 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Eliminate recursive mutex in compat fb ioctl path

fb_compat_ioctl grabbed the fb mutex and then called fb_ioctl, which also grabs the same mutex. I traced through all existing fb_compat_ioctl functions in the various fb drivers and found that they also transform their arguments and call the native fb_ioctl function. So, it is correct to just remove the mutex_lock/mutex_unlock pair in the top-level compat path.

---
 drivers/video/fbmem.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/video/fbmem.c +0 -2
index cd5f20d..548cf26 100644
@@ -1253,7 +1253,6 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	struct fb_ops *fb = info->fbops;
 	long ret = -ENOIOCTLCMD;
 
-	mutex_lock(&info->lock);
 	switch(cmd) {
 	case FBIOGET_VSCREENINFO:
 	case FBIOPUT_VSCREENINFO:
@@ -1279,7 +1278,6 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			ret = fb->fb_compat_ioctl(info, cmd, arg);
 		break;
 	}
-	mutex_unlock(&info->lock);
 	return ret;
 }
 #endif
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 5 lines · Keith Packard

fb_compat_ioctl grabbed the fb mutex and then called fb_ioctl, which also grabs the same mutex. I traced through all existing fb_compat_ioctl functions in the various fb drivers and found that they also transform their arguments and call the native fb_ioctl function. So, it is correct to just remove the mutex_lock/mutex_unlock pair in the top-level compat path.

Last week I submitted an alternative fix: http://lkml.org/lkml/2008/10/31/162

Probably Rafael wants to keep track of this regression, too?

Quoted 18 lines
---
 drivers/video/fbmem.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/video/fbmem.c +0 -1
index cd5f20d..548cf26 100644
@@ -1253,7 +1253,6 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	struct fb_ops *fb = info->fbops;
 	long ret = -ENOIOCTLCMD;
 
-	mutex_lock(&info->lock);
 	switch(cmd) {
 	case FBIOGET_VSCREENINFO:
 	case FBIOPUT_VSCREENINFO:

drivers/video/fbmem.c fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 1283

Quoted 7 lines
drivers/video/fbmem.c +0 -1
@@ -1279,7 +1278,6 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			ret = fb->fb_compat_ioctl(info, cmd, arg);
 		break;
 	}
-	mutex_unlock(&info->lock);
 	return ret;
 }
 #endif

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   [email protected]
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V. VAT BE 0413.825.160 · RPR Brussels Fortis · BIC GEBABEBB · IBAN BE41293037680010