Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp193977rwb; Wed, 9 Nov 2022 00:48:11 -0800 (PST) X-Google-Smtp-Source: AMsMyM6W5EDUH7R/wjmQt0GHlq9mH17SLSwav3EDjsV9QQFyuNDWv2wANBnwunTt0rXWYhLQcBUP X-Received: by 2002:a17:907:84a:b0:733:735:2b1a with SMTP id ww10-20020a170907084a00b0073307352b1amr56160726ejb.290.1667983691168; Wed, 09 Nov 2022 00:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667983691; cv=none; d=google.com; s=arc-20160816; b=jsaMDkMSIPy+9G+W8vMmynDa2275ladriXnOKRc0qmfIFHveXt2yTM4G8oQQATEnbO qq41iTVr4lcKR3rVec16puX7nYK7wczsD+RPpkIIdz1Q+yLDgMaIY3RJzbRC4+skuspt NBaA0gwM78srKK+AWV/Yc7WRdWQGKmTpDnBsJ10TXLYmC9RMtkGlyUZkruygkhb3zwbr LJt9QS16whluPmMuL+PaLNmG4g4+ovxKHNVu+wLpwgYQuWrza1qEldeGl5M8c2amWmId xBhteB+DGj+fg4+ZRDEyVzr2I5uFPn8YpeJt2PWvUMi9dmSA0MZFZRUsMbRoNZF8xUgV PfFw== 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=G5YfBp4yqGNcz/t+IfHPsK2vR0s79n579pWW/ilhdaw=; b=J3JmhFfh5Qzyxzuea3hd0EDf8LEhwF6KS7+I0Mfhu3lAOEtj9UnfQVr//gdhbtbnZn 4S94k+kpZi6+cWhzTKf62f8/3S8xIRxiR6gB3uoEksWOd6Kn0eDWgkUk7A1rQXfvCZQk C5MdfPddldhCJLlupG61yPm11zBVHrwHfOjLUdWDKkNUhuQrf7qdaV0BdwYMLu+RtQnd 7MiTv69i7roS9dJXZjp5VfuqwXXDkpVHuQJfwItF5SvZW6hOHpnhuC0gjr3YbQNGFrUT +ZCX6CzdLCSWoiN/cfphjUaf/qRdeUPTGxL46ZoJ3NDyMZu7qfM2pUFn4JeDT0EfDiqy j1Yg== 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 f22-20020a0564021e9600b004663240e1f7si13616674edf.620.2022.11.09.00.47.47; Wed, 09 Nov 2022 00:48:11 -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 S229973AbiKII2Q (ORCPT + 93 others); Wed, 9 Nov 2022 03:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbiKII1x (ORCPT ); Wed, 9 Nov 2022 03:27:53 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07D8013D63; Wed, 9 Nov 2022 00:27:52 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N6dPj35N4zmVlR; Wed, 9 Nov 2022 16:27:37 +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:49 +0800 From: Wang Yufen To: , CC: , Wang Yufen , Dan Murphy Subject: [PATCH 04/13] leds: lm3692x: Fix devm vs. non-devm ordering Date: Wed, 9 Nov 2022 16:48:05 +0800 Message-ID: <1667983694-15040-5-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: 9699cb6bbef2 ("leds: lm3692x: Introduce LM3692x dual string driver") Signed-off-by: Wang Yufen Cc: Dan Murphy --- drivers/leds/leds-lm3692x.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index 54b4662..aa1b0cc 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -456,6 +456,11 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) return ret; } +static void lm3692x_mutex_destroy(void *lock) +{ + mutex_destroy(lock); +} + static int lm3692x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -472,6 +477,11 @@ static int lm3692x_probe(struct i2c_client *client, led->model_id = id->driver_data; i2c_set_clientdata(client, led); + ret = devm_add_action_or_reset(&client->dev, lm3692x_mutex_destroy, + &led->lock); + if (ret) + return ret; + led->regmap = devm_regmap_init_i2c(client, &lm3692x_regmap_config); if (IS_ERR(led->regmap)) { ret = PTR_ERR(led->regmap); @@ -496,7 +506,6 @@ static void lm3692x_remove(struct i2c_client *client) struct lm3692x_led *led = i2c_get_clientdata(client); lm3692x_leds_disable(led); - mutex_destroy(&led->lock); } static const struct i2c_device_id lm3692x_id[] = { -- 1.8.3.1