From patchwork Tue Apr 21 12:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 11501239 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25F72159A for ; Tue, 21 Apr 2020 12:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E4E520753 for ; Tue, 21 Apr 2020 12:46:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="jlhlrCCT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728621AbgDUMqs (ORCPT ); Tue, 21 Apr 2020 08:46:48 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42738 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728524AbgDUMqs (ORCPT ); Tue, 21 Apr 2020 08:46:48 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03LCkhvd123694; Tue, 21 Apr 2020 07:46:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587473203; bh=LskT7Fluz1afemuppgQ3E8smEknLw7ty0G3qU//E2DU=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=jlhlrCCTFQ5QbZAt5Qq0LdKgOwAshdU9CIWB8RBlyISBB04WIcLNPCbgk7KVOMHtB m64BiqhuP7syt9nHh557gVX0zdpGn8zKaWIoGeSK8dTMt+DakBVLiS9tWeSfB+XMtT gSYtWBh2moV8PmyMbb5GU8XgVLruB8IHAsuw8WwU= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03LCkhaj031312; Tue, 21 Apr 2020 07:46:43 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 21 Apr 2020 07:46:39 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 21 Apr 2020 07:46:39 -0500 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03LCkVx6037462; Tue, 21 Apr 2020 07:46:38 -0500 From: Tomi Valkeinen To: Lee Jones , Daniel Thompson , Jingoo Han , Bartlomiej Zolnierkiewicz , , CC: Tomi Valkeinen Subject: [PATCHv2 3/4] backlight: led_bl: add led_access locking Date: Tue, 21 Apr 2020 15:46:28 +0300 Message-ID: <20200421124629.20977-4-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421124629.20977-1-tomi.valkeinen@ti.com> References: <20200421124629.20977-1-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org led_bl does not lock 'led_access' when calling led_sysfs_disable and led_sysfs_enable, causing the below WARN. Add the locking. WARNING: CPU: 0 PID: 223 at drivers/leds/led-core.c:353 led_sysfs_disable+0x4c/0x5c Signed-off-by: Tomi Valkeinen Reviewed-by: Daniel Thompson --- drivers/video/backlight/led_bl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c index c46ecdfe8b0a..63693c4f0883 100644 --- a/drivers/video/backlight/led_bl.c +++ b/drivers/video/backlight/led_bl.c @@ -216,8 +216,11 @@ static int led_bl_probe(struct platform_device *pdev) return PTR_ERR(priv->bl_dev); } - for (i = 0; i < priv->nb_leds; i++) + for (i = 0; i < priv->nb_leds; i++) { + mutex_lock(&priv->leds[i]->led_access); led_sysfs_disable(priv->leds[i]); + mutex_unlock(&priv->leds[i]->led_access); + } backlight_update_status(priv->bl_dev); @@ -233,8 +236,11 @@ static int led_bl_remove(struct platform_device *pdev) backlight_device_unregister(bl); led_bl_power_off(priv); - for (i = 0; i < priv->nb_leds; i++) + for (i = 0; i < priv->nb_leds; i++) { + mutex_lock(&priv->leds[i]->led_access); led_sysfs_enable(priv->leds[i]); + mutex_unlock(&priv->leds[i]->led_access); + } return 0; }