Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp198861rwb; Wed, 9 Nov 2022 00:54:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM7jVISPSC3xFiEWrsWI3UfSiTuJzCiFfwLOyvjo5bX99sqQpd8wBZMWLU16r8aTwE8YjfTN X-Received: by 2002:a17:902:f605:b0:186:6feb:7eb4 with SMTP id n5-20020a170902f60500b001866feb7eb4mr59610287plg.134.1667984072380; Wed, 09 Nov 2022 00:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667984072; cv=none; d=google.com; s=arc-20160816; b=NtyNlYVJHvBB1nUzJvxInlHohrEEjOo+O6z/zlWRFIJRB2ZhxBUhkitvmmL3R/Quh4 HEJSoFKfSYtmA+p/vD4Wo3kXKINuyTXQDtbw68j9A7HU6gwd58jNG2jU3Dnsabq36GY8 hUDJtIY7R4+dpSVIrNTL9gqLdpDWpp/2hhg9DSgL68uLBhsDXmaunw49f9EGX9xWlETW +x3tSzIx301Cp9kxggFu+bejh32yr7NXWmHogj1y5XV4XmsSaD/jaFHOXyywEsoqhItM HhYxrZduWCd8hRSLP/v/6pC4OhSEexXBJm0xucih3V0ADzuyjU4/pqVpIhitPiER12B3 uY0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=SyhRz8P495bku6SapQLrh2NoW4TNt7xJsSUX1q8c/mQ=; b=tKQ1Ivh1+xF5HZH6JT4cVkPsIjNhbM2tHKc6BHpQEXnvTPhMAv93c+KhG7E+OO4uuU jakZAxrF7JmqtduhC1LbbBWbCy2s8nT/0BxPcza7bEb4jslSCN3OzsU1OtHihRFro71e 83Kuv+S4dCvhmpidEOG6mGxoZcLGx7pyQ4sZf+4Cc7gTPXHxCDlutfA+jbeuxEtXKNBS o713XaiPN8VBRLvpAloaxF1qyTD2LBDY0oVFDu53cWAUYb/bmObhuTka0CQH7WJlYivG UuSna7UE7xC6X5NT8VuQQprAVVrfgOqgqVVsnGc3gRHbOuKoft1b/hrASz7UX/17FDG0 4TmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a63164a000000b004541962a9basi16623502pgw.701.2022.11.09.00.54.20; Wed, 09 Nov 2022 00:54:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbiKII23 (ORCPT + 93 others); Wed, 9 Nov 2022 03:28:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229871AbiKII1y (ORCPT ); Wed, 9 Nov 2022 03:27:54 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4786B13D16; Wed, 9 Nov 2022 00:27:53 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N6dPW0SvtzHvk6; Wed, 9 Nov 2022 16:27:27 +0800 (CST) Received: from localhost.localdomain (10.175.112.70) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 9 Nov 2022 16:27:51 +0800 From: Wang Yufen To: , CC: , Wang Yufen , Dan Murphy Subject: [PATCH 07/13] leds: lp8860: Fix devm vs. non-devm ordering Date: Wed, 9 Nov 2022 16:48:08 +0800 Message-ID: <1667983694-15040-8-git-send-email-wangyufen@huawei.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1667983694-15040-1-git-send-email-wangyufen@huawei.com> References: <1667983694-15040-1-git-send-email-wangyufen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When non-devm resources are allocated they mustn't be followed by devm allocations, otherwise it will break the tear down ordering and might lead to crashes or other bugs during ->remove() stage. Fix this by wrapping mutex_destroy() call with devm_add_action_or_reset(). Fixes: a2169c9b762a ("leds: lp8860: Various fixes to align with LED framework") Signed-off-by: Wang Yufen Cc: Dan Murphy --- drivers/leds/leds-lp8860.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index e2b36d3..ca73d91 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -375,6 +375,11 @@ static int lp8860_init(struct lp8860_led *led) .cache_type = REGCACHE_NONE, }; +static void lp8860_mutex_destroy(void *lock) +{ + mutex_destroy(lock); +} + static int lp8860_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -408,6 +413,10 @@ static int lp8860_probe(struct i2c_client *client, led->led_dev.brightness_set_blocking = lp8860_brightness_set; mutex_init(&led->lock); + ret = devm_add_action_or_reset(&client->dev, lp8860_mutex_destroy, + &led->lock); + if (ret) + return ret; i2c_set_clientdata(client, led); @@ -459,8 +468,6 @@ static void lp8860_remove(struct i2c_client *client) dev_err(&led->client->dev, "Failed to disable regulator\n"); } - - mutex_destroy(&led->lock); } static const struct i2c_device_id lp8860_id[] = { -- 1.8.3.1