From patchwork Fri Apr 3 12:50:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6156471 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1398BF4A6 for ; Fri, 3 Apr 2015 12:50:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE164203DB for ; Fri, 3 Apr 2015 12:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5A7B203E1 for ; Fri, 3 Apr 2015 12:50:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506AbbDCMuc (ORCPT ); Fri, 3 Apr 2015 08:50:32 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:43608 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752473AbbDCMub (ORCPT ); Fri, 3 Apr 2015 08:50:31 -0400 Received: from ayla.of.borg ([84.193.93.87]) by andre.telenet-ops.be with bizsmtp id BQqT1q00a1t5w8s01QqTqe; Fri, 03 Apr 2015 14:50:28 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1Ye13L-0006C2-KB; Fri, 03 Apr 2015 14:50:27 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1Ye13R-0006dS-34; Fri, 03 Apr 2015 14:50:33 +0200 From: Geert Uytterhoeven To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , Laurent Pinchart Cc: linux-fbdev@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] fbdev: sh_mobile_lcdc: Fix destruction of uninitialized mutex Date: Fri, 3 Apr 2015 14:50:28 +0200 Message-Id: <1428065428-25473-1-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If sh_mobile_lcdc_probe() fails after the allocation of driver-private data, but before the initialization of all channels, a warning will be printed due to the destruction of an uninitialized mutex: WARNING: CPU: 0 PID: 1 at kernel/locking/mutex-debug.c:116 mutex_destroy+0x5c/0x7c() DEBUG_LOCKS_WARN_ON(mutex_is_locked(lock)) ... Backtrace: ... [] (mutex_destroy) from [] (sh_mobile_lcdc_remove+0x1bc/0x230) r4:df6a4800 r3:00000000 [] (sh_mobile_lcdc_remove) from [] (sh_mobile_lcdc_probe+0xd54/0xe28) Move the initialization of the mutexes from sh_mobile_lcdc_channel_init() to immediately after the allocation of driver-private data to fix this. Note that the interrupt number is moved to a new variable "irq", so we can reuse the existing variable "i" for iterating over the channels. Signed-off-by: Geert Uytterhoeven Acked-by: Laurent Pinchart --- drivers/video/fbdev/sh_mobile_lcdcfb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c index d3013cd9f9769663..97141da154c663b8 100644 --- a/drivers/video/fbdev/sh_mobile_lcdcfb.c +++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c @@ -2605,7 +2605,6 @@ sh_mobile_lcdc_channel_init(struct sh_mobile_lcdc_chan *ch) unsigned int max_size; unsigned int i; - mutex_init(&ch->open_lock); ch->notify = sh_mobile_lcdc_display_notify; /* Validate the format. */ @@ -2704,7 +2703,7 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev) struct resource *res; int num_channels; int error; - int i; + int irq, i; if (!pdata) { dev_err(&pdev->dev, "no platform data defined\n"); @@ -2712,8 +2711,8 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - i = platform_get_irq(pdev, 0); - if (!res || i < 0) { + irq = platform_get_irq(pdev, 0); + if (!res || irq < 0) { dev_err(&pdev->dev, "cannot get platform resources\n"); return -ENOENT; } @@ -2726,16 +2725,18 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev) priv->dev = &pdev->dev; priv->meram_dev = pdata->meram_dev; + for (i = 0; i < ARRAY_SIZE(priv->ch); i++) + mutex_init(&priv->ch[i].open_lock); platform_set_drvdata(pdev, priv); - error = request_irq(i, sh_mobile_lcdc_irq, 0, + error = request_irq(irq, sh_mobile_lcdc_irq, 0, dev_name(&pdev->dev), priv); if (error) { dev_err(&pdev->dev, "unable to request irq\n"); goto err1; } - priv->irq = i; + priv->irq = irq; atomic_set(&priv->hw_usecnt, -1); for (i = 0, num_channels = 0; i < ARRAY_SIZE(pdata->ch); i++) {