Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp217312rwb; Wed, 9 Nov 2022 01:12:50 -0800 (PST) X-Google-Smtp-Source: AMsMyM4C0XxaOd+iyTyo5AZjxWcodZhjAmcZAMbXrweDH5wuV3LpGnZ/6LHvlGyWFO08M7l1gjnJ X-Received: by 2002:a17:90a:c691:b0:212:fd5f:1ab8 with SMTP id n17-20020a17090ac69100b00212fd5f1ab8mr76925782pjt.11.1667985170743; Wed, 09 Nov 2022 01:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667985170; cv=none; d=google.com; s=arc-20160816; b=Snz++T2zfcjlfTtRBcbO+ua7+SxdXWcgdQ6fqwKS01yCNCHJko4G2hnThbDKVQDVKn ktDuNomWa9DciNZGoD4Zgl2MWu8y0V0AFS57yzbsZByTdstrRL8WHVMwtB99Qe5eiO4D zd+rVME926YCmDVjB6bCo4WARWpwvjUlbpk2o/KFdB8ojNMxjNylPP7sGzoq3vR/R9ba fwbZ4iT9dTWth9w/q/NHJRgMtEgZVt5WxIA5wfVk/BWeeKWwDG+E8SUtXQjRVc0MRv/n 1HVL76VpD6kIifwi+zZ2/PhxAuoItz10nggQGVNQTkdSnX57An5hlomKfkFV/cssgjCD 3I0w== 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=JCoIWqDeumZapjzyVrJ39jYQjoxecSFd4+psEhsf2s4=; b=iWfx6uljWkN/5DamDXEoMfOFyLmCEwZczjBoGJoi+KMI17wNMBCo50ZfFS6xFuZWnZ fkXQJfD/lXSer20E/f6BaVMCbEtmFzE1pjYqpIo00SdqMEgmp4lG+VOE2U+t48jTZage I03D0rnTyB0aTS3DGoGuG3wYR/zvEzZDdvfv4nHSAV6eQet9XGDwKzpOqnh8Qq0mWHX7 gm9ZnU5jMDahZVFqWjLg5Tk9Utix5t04Rzwf+3WW+nagcQkODhUYEb82xVYeKCO2/37I CfA4BJe8kuMU3KJ0ZPxD0qkQf9kVX6aXt4JxVesUtgszTEE7rAv1sSB66xbdJGizgKon ds4g== 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 g12-20020a170902740c00b00176be2315dcsi15376093pll.260.2022.11.09.01.12.39; Wed, 09 Nov 2022 01:12:50 -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 S229956AbiKII2K (ORCPT + 93 others); Wed, 9 Nov 2022 03:28:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiKII1w (ORCPT ); Wed, 9 Nov 2022 03:27:52 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF61E13D52; Wed, 9 Nov 2022 00:27:51 -0800 (PST) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N6dPm58J9zRnvt; Wed, 9 Nov 2022 16:27:40 +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 03/13] leds: lm3532: Fix devm vs. non-devm ordering Date: Wed, 9 Nov 2022 16:48:04 +0800 Message-ID: <1667983694-15040-4-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: bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver") Signed-off-by: Wang Yufen Cc: Dan Murphy --- drivers/leds/leds-lm3532.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index db64d44..a052966 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -663,6 +663,11 @@ static int lm3532_parse_node(struct lm3532_data *priv) return ret; } +static void lm3532_mutex_destroy(void *lock) +{ + mutex_destroy(lock); +} + static int lm3532_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -693,6 +698,11 @@ static int lm3532_probe(struct i2c_client *client, } mutex_init(&drvdata->lock); + ret = devm_add_action_or_reset(&client->dev, lm3532_mutex_destroy, + &drvdata->lock); + if (ret) + return ret; + i2c_set_clientdata(client, drvdata); ret = lm3532_parse_node(drvdata); -- 1.8.3.1