From patchwork Sun Oct 23 12:37:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Briskin X-Patchwork-Id: 9391105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A99D0607FF for ; Sun, 23 Oct 2016 12:38:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EC2D28AE7 for ; Sun, 23 Oct 2016 12:38:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 831D928B1F; Sun, 23 Oct 2016 12:38:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3BEF28AE7 for ; Sun, 23 Oct 2016 12:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754014AbcJWMir (ORCPT ); Sun, 23 Oct 2016 08:38:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35934 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751963AbcJWMir (ORCPT ); Sun, 23 Oct 2016 08:38:47 -0400 Received: by mail-wm0-f66.google.com with SMTP id f193so5696426wmg.3 for ; Sun, 23 Oct 2016 05:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=6MTGnsXVbweovyLhbgAHoipvPQXhgOlvb6eOEebyp4w=; b=hnbVsdWaHHEFVrMCDidgVi6W3TxLqrnLp/Cjj4iwZrTfwo5m83uMWS8M/TBwATHYh7 YbuQZGsuZv+ZVvIlim7YYocD+j15MKbGs+0k/mGYYY6x/mNsZ+Y926RYVNiMq86h1fOm Ioj89Ei0HO6QLnpay+BumnfhFOfUZpM9STXgcyvFkSaR1OqzTUrVxxDR6N6H3u+Cd+nm FzJpVMIKMfop5f/M95yCgStrqVNVRajIOGxca0eTLAzs1okx22ZXCCr7GKcFKlxpq8Tu pPUJjduf2/egekpYzUVQAU3k8sP0tMUlAiNLKv50lkdAkn1cL6j2Dl0rKWwQIQboUSw2 n9iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6MTGnsXVbweovyLhbgAHoipvPQXhgOlvb6eOEebyp4w=; b=fYWbQViN0mdHzPCqo+EDAstEr2YYpALzTJxPdIMGURonltDFePQ3nAww30GVhK8Y8E Z4QoBFAUjBGPGAqJ+Q9b+H3joHuLkwh62oWKkPEmm1i15bdtmlFQx67qka22h92tW0Vz ZnNoEACA6gkdZ4ojFOTzoMv+PwTwI5pTqsDaRDZInh8CWI2hJkg0qG7HHhj6saV5xI4M +yFWV6H4YKYMWh+ihEknvOYSOoryH9E+osNmGALC5MW9BYwgZN7JuOQG5i7Huv3zDXH7 TmqHnOJf9V/GTVLzj+feeLmFCNfuMsTVsaKD3G+C9euLFzf9rUPRMtt4mChiwXKkJjXJ /97Q== X-Gm-Message-State: ABUngvfIbSaWf/OEjkctWlv5R1yYZCn1i0cv6C5h2ovy6KsfhJPCtElB5o6yyq58+n1kBQ== X-Received: by 10.194.114.40 with SMTP id jd8mr9636581wjb.191.1477226325456; Sun, 23 Oct 2016 05:38:45 -0700 (PDT) Received: from localhost.localdomain ([77.125.246.229]) by smtp.googlemail.com with ESMTPSA id wn5sm13573900wjb.42.2016.10.23.05.38.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Oct 2016 05:38:44 -0700 (PDT) From: Alex Briskin To: devel@driverdev.osuosl.org Cc: Alex Briskin , linux-fbdev@vger.kernel.org, gregkh@linuxfoundation.org, teddy.wang@siliconmotion.com, sudipm.mukherjee@gmail.com, insafonov@gmail.com, remyoudompheng@gmail.com Subject: [PATCH] staging: sm750fb: Fix lock context error Date: Sun, 23 Oct 2016 15:37:57 +0300 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }