public inbox for linux-fbdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: sm750fb: Fix lock context error
@ 2016-10-23 12:37 Alex Briskin
  2016-10-24 10:41 ` Dan Carpenter
  2016-10-24 12:12 ` br.shurik
  0 siblings, 2 replies; 3+ messages in thread
From: Alex Briskin @ 2016-10-23 12:37 UTC (permalink / raw)
  To: linux-fbdev

Sparse error fix - different lock contexts for basic block.
Acquirement and release of spin lock was dependent on two separate
unprotected variable evaluations. Instead the condition evaluation result
is stored in a local boolean variable to make sure that the same context
that called the spin_lock will evoke spin_unlock.

Signed-off-by: Alex Briskin <br.shurik@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 0663ec0..4f0f98e 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -164,6 +164,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 	struct sm750_dev *sm750_dev;
 	unsigned int base, pitch, Bpp, rop;
 	u32 color;
+	bool lock_in_this_context = false;
 
 	if (info->state != FBINFO_STATE_RUNNING)
 		return;
@@ -187,7 +188,8 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 	 * If not use spin_lock,system will die if user load driver
 	 * and immediately unload driver frequently (dual)
 	 */
-	if (sm750_dev->fb_count > 1)
+	lock_in_this_context = sm750_dev->fb_count > 1;
+	if (lock_in_this_context)
 		spin_lock(&sm750_dev->slock);
 
 	sm750_dev->accel.de_fillrect(&sm750_dev->accel,
@@ -195,7 +197,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
 				     region->dx, region->dy,
 				     region->width, region->height,
 				     color, rop);
-	if (sm750_dev->fb_count > 1)
+	if (lock_in_this_context)
 		spin_unlock(&sm750_dev->slock);
 }
 
@@ -205,6 +207,7 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 	struct lynxfb_par *par;
 	struct sm750_dev *sm750_dev;
 	unsigned int base, pitch, Bpp;
+	bool lock_in_this_context = false;
 
 	par = info->par;
 	sm750_dev = par->dev;
@@ -221,7 +224,8 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 	 * If not use spin_lock, system will die if user load driver
 	 * and immediately unload driver frequently (dual)
 	 */
-	if (sm750_dev->fb_count > 1)
+	lock_in_this_context = sm750_dev->fb_count > 1;
+	if (lock_in_this_context)
 		spin_lock(&sm750_dev->slock);
 
 	sm750_dev->accel.de_copyarea(&sm750_dev->accel,
@@ -229,7 +233,7 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
 				     base, pitch, Bpp, region->dx, region->dy,
 				     region->width, region->height,
 				     HW_ROP2_COPY);
-	if (sm750_dev->fb_count > 1)
+	if (lock_in_this_context)
 		spin_unlock(&sm750_dev->slock);
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-24 12:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-23 12:37 [PATCH] staging: sm750fb: Fix lock context error Alex Briskin
2016-10-24 10:41 ` Dan Carpenter
2016-10-24 12:12 ` br.shurik

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