From patchwork Sat Jul 30 20:26:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1022962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6UKQrbE031932 for ; Sat, 30 Jul 2011 20:26:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752781Ab1G3U0y (ORCPT ); Sat, 30 Jul 2011 16:26:54 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:56034 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752724Ab1G3U0w (ORCPT ); Sat, 30 Jul 2011 16:26:52 -0400 Received: from localhost.localdomain (unknown [91.178.149.42]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9599735A00; Sat, 30 Jul 2011 20:26:50 +0000 (UTC) From: Laurent Pinchart To: linux-fbdev@vger.kernel.org Cc: linux-sh@vger.kernel.org Subject: [PATCH 2/4] fbdev: sh_mobile_meram: Validate ICB configuration outside mutex Date: Sat, 30 Jul 2011 22:26:53 +0200 Message-Id: <1312057615-29123-3-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1312057615-29123-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1312057615-29123-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 30 Jul 2011 20:26:55 +0000 (UTC) Validate as much of the requested ICB configuration as possible outside of the mutex-protected region when registering ICBs. Signed-off-by: Laurent Pinchart --- drivers/video/sh_mobile_meram.c | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/video/sh_mobile_meram.c b/drivers/video/sh_mobile_meram.c index 85577cf..25a7118 100644 --- a/drivers/video/sh_mobile_meram.c +++ b/drivers/video/sh_mobile_meram.c @@ -410,24 +410,22 @@ static int sh_mobile_meram_register(struct sh_mobile_meram_info *pdata, xres, yres, (!pixelformat) ? "yuv" : "rgb", base_addr_y, base_addr_c); - mutex_lock(&priv->lock); - /* we can't handle wider than 8192px */ if (xres > 8192) { dev_err(&pdev->dev, "width exceeding the limit (> 8192)."); - error = -EINVAL; - goto err; - } - - if (priv->used_meram_cache_regions + 2 > SH_MOBILE_MERAM_ICB_NUM) { - dev_err(&pdev->dev, "no more ICB available."); - error = -EINVAL; - goto err; + return -EINVAL; } /* do we have at least one ICB config? */ if (cfg->icb[0].marker_icb < 0 || cfg->icb[0].cache_icb < 0) { dev_err(&pdev->dev, "at least one ICB is required."); + return -EINVAL; + } + + mutex_lock(&priv->lock); + + if (priv->used_meram_cache_regions + 2 > SH_MOBILE_MERAM_ICB_NUM) { + dev_err(&pdev->dev, "no more ICB available."); error = -EINVAL; goto err; }