From patchwork Mon Jun 9 20:38:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 896624 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AEE022170B; Mon, 9 Jun 2025 20:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501544; cv=none; b=UYHIb10q/kIcysjxAdMgg/N3o7EDavlay7QpxXXg9kynGTvEWIqBSt3f+muzeWpR0GG7wvXD7m7Kl6K8Op9oZB3nWv1rrlwp+L6rLPh3t3tM3mY0KW7WC7i/77NuLtwlPWeGmUx22EKagsjpYopt0UiqWUoLkt0H6ZzE0DnTlU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501544; c=relaxed/simple; bh=azLvpNS6ccFIPAjwzhhSs7C802wsRdQiR7hKzlK9MIE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d7zQrfdCeWp27Kg1WUkiwSL4i4K1UUGBK2fWqGDnf0BXJix+ulIzPelJaSE4bVegEOlvT8jF4eJdQkAYcp5ktIkSgoTi5h2vLbx+zG101by+5eBGdDLIdMTIomKe77RNmjBK1hiyos6zV2g8Wr/jFNNcYj85uDLDKkOJpWfmIr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=OyJQr67L; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="OyJQr67L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1749501539; bh=azLvpNS6ccFIPAjwzhhSs7C802wsRdQiR7hKzlK9MIE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OyJQr67LA/qATwAcM2WhqumB6/h5LHabx1HOOqJJj/4aqgOxt4mQCoNGLeTYJ3tq0 mw8KIqLu9J10stqYLvrCn/XJNHttRJc/1Azmxulg1VSZC2Ob3A4/pH5LpCNyZe9K53 RZqdxzQIjcTm/Idkzmw9hiYYqMALgBTqK12YJROU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 09 Jun 2025 22:38:37 +0200 Subject: [PATCH v6 1/3] spi: spi-nxp-fspi: check return value of devm_mutex_init() Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250609-must_check-devm_mutex_init-v6-1-9540d5df9704@weissschuh.net> References: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> In-Reply-To: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> To: Peter Zijlstra , Ingo Molnar , Waiman Long , Boqun Feng , Vicentiu Galanopulo , Will Deacon , Han Xu , Haibo Chen , Yogesh Gaur , Mark Brown , Lee Jones , Pavel Machek , Andrew Davis Cc: Andy Shevchenko , linux-kernel@vger.kernel.org, Bartosz Golaszewski , Bartosz Golaszewski , linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-leds@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1749501538; l=1078; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=azLvpNS6ccFIPAjwzhhSs7C802wsRdQiR7hKzlK9MIE=; b=7Tex+6NkzoKF+8wCbpZPkHLLVD1gTer+8CN7AMvXQEYZbIKYLsA0sVqRAYKiDEmbz5Dzf9VG4 NNarAPkm1mbBgfavw87ucpapLycpxvVCZSoxqzH7ufaohe9/dLEgjBG X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check. Fixes: 48900813abd2 ("spi: spi-nxp-fspi: remove the goto in probe") Signed-off-by: Thomas Weißschuh --- drivers/spi/spi-nxp-fspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index e63c77e418231cd0698ffb73eeeebfbe63cc3065..f3d5765054132cd18b7257439ece971f58e9ceb2 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -1273,7 +1273,9 @@ static int nxp_fspi_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "Failed to request irq\n"); - devm_mutex_init(dev, &f->lock); + ret = devm_mutex_init(dev, &f->lock); + if (ret) + return dev_err_probe(dev, ret, "Failed to initialize lock\n"); ctlr->bus_num = -1; ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT; From patchwork Mon Jun 9 20:38:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 896623 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 624D1221721; Mon, 9 Jun 2025 20:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501545; cv=none; b=f8gSYLmPgBYn7zrXViPDkPo1RY9nVpRTHnOe6zNi+5dpJlYB/McTjpXAZG4cXBW+EzcfDna1Zah98u3xgZiBIYUTz4j6UGfCyZQB7OT0+I9P73xD+RjDLeHoRCNXAJqUDfkThhM6/dLifC5F5zDGNRiDi03+XJD6sYoutARv+RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501545; c=relaxed/simple; bh=G5wPqDXS58NnrzSV5vgw2JHG+OHUUSaZGYOXaC8tXy0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D02aiTfAT35Q2iIiBGEfIuRgtcdR5fUp8LdkVqj6zIqAgQ9HdIhYpsoOinx41wAGEJIDqaKaN7XwHpQgc30jiB6k6eTUNP4xFhr+PJfGZlvWIVmvgVdOaXBsVXxLSviSt4UY3Kcj4uuH3k+6r8mv+kZ68ezCnvVAZhHfv7Xwqf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=AfQ6FJ5f; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="AfQ6FJ5f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1749501539; bh=G5wPqDXS58NnrzSV5vgw2JHG+OHUUSaZGYOXaC8tXy0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AfQ6FJ5ffdnEG9K0pTjGqAbq21xj9jXoU57iahPD5Nx9r9BeTroAB90BDT8QdQWVy oKkI1UIY6PSUHgSJBDEkMLFxrUEXq+mh0P2aIaANH10FOJEDCsbeXDzZ79aGdG09Xk 4xOXl8lAhjRk6MW8nnuorQNmrRmgwdMe9bto8fJM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 09 Jun 2025 22:38:38 +0200 Subject: [PATCH v6 2/3] leds: lp8860: Check return value of devm_mutex_init() Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250609-must_check-devm_mutex_init-v6-2-9540d5df9704@weissschuh.net> References: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> In-Reply-To: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> To: Peter Zijlstra , Ingo Molnar , Waiman Long , Boqun Feng , Vicentiu Galanopulo , Will Deacon , Han Xu , Haibo Chen , Yogesh Gaur , Mark Brown , Lee Jones , Pavel Machek , Andrew Davis Cc: Andy Shevchenko , linux-kernel@vger.kernel.org, Bartosz Golaszewski , Bartosz Golaszewski , linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-leds@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1749501538; l=1160; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=G5wPqDXS58NnrzSV5vgw2JHG+OHUUSaZGYOXaC8tXy0=; b=JOy/hussvTbGS4IAwYip3ZRXXIumOP1ljb9PL4bWOiKX3BAwcYeQ/qv6YgJV1rmGIiioleS6f 6tDWP2BK4uGBiOFZPjS/EGPQVt7jiSfjg0p+AAahpkM40NyDHkO4eES X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using devm variant of it. Tomorrow it may even leak something. Add the missed check. Fixes: 87a59548af95 ("leds: lp8860: Use new mutex guards to cleanup function exits") Signed-off-by: Thomas Weißschuh --- drivers/leds/leds-lp8860.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 52b97c9f2a03567aa12d4f63a951593a5e7017d5..0962c00c215a11f555a7878a3b65824b5219a1fa 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -307,7 +307,9 @@ static int lp8860_probe(struct i2c_client *client) led->client = client; led->led_dev.brightness_set_blocking = lp8860_brightness_set; - devm_mutex_init(&client->dev, &led->lock); + ret = devm_mutex_init(&client->dev, &led->lock); + if (ret) + return dev_err_probe(&client->dev, ret, "Failed to initialize lock\n"); led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config); if (IS_ERR(led->regmap)) { From patchwork Mon Jun 9 20:38:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 895121 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8622322129F; Mon, 9 Jun 2025 20:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501543; cv=none; b=SPtmGH521uczbAxpJl3AZ3wck1oTSpfZNJK0/yNCC8FoLQ76TsN9KcmIMgpc50yd29/aToBY3p6vovmAbFKfM4OxTE95IgSZUBvif3EYYvh/r40xbtuWdE6Gcb7in6hUmT9C3e9GIg+sWvLFWaT0o5JKIyIEQKgLjpiN6hnki8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749501543; c=relaxed/simple; bh=/FW1uODFNygTPBiads/Cgva/fZBdnCPVHS77URlMjjc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V5QlHZvYTJmfJjkuKMvmu1d7CmGB+hcKnHaRnCxyWz7nyz5EB6ogeSFt0LYJ7AntktET3j9YKwV5etXRZLM7Eep2GMmTfxY9ktfE4H5cp3++Ft9Q7/glK8SUgVFSYc6qtKZ4+PCS6eXRmzAy9GYLgXNZHQxwnUn5Cc0QMIyxIgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=RQ/h7KoF; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="RQ/h7KoF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1749501539; bh=/FW1uODFNygTPBiads/Cgva/fZBdnCPVHS77URlMjjc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RQ/h7KoFVxyEaL3gOrcwRIrSgiUi8tpf+8bZ1J3cmHacz1rZSlBzejqnzNA6GJH05 bfa6DvVbFooTRNtO1DccruKYL07wctByi6ad/WxxZxTwEs1/r55W8AD32nJcQP9ng9 k++3zu4wwvtQi17CUEWu2WFdHxXlKbqOsQHqAtV0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 09 Jun 2025 22:38:39 +0200 Subject: [PATCH v6 3/3] locking/mutex: Mark devm_mutex_init() as __must_check Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250609-must_check-devm_mutex_init-v6-3-9540d5df9704@weissschuh.net> References: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> In-Reply-To: <20250609-must_check-devm_mutex_init-v6-0-9540d5df9704@weissschuh.net> To: Peter Zijlstra , Ingo Molnar , Waiman Long , Boqun Feng , Vicentiu Galanopulo , Will Deacon , Han Xu , Haibo Chen , Yogesh Gaur , Mark Brown , Lee Jones , Pavel Machek , Andrew Davis Cc: Andy Shevchenko , linux-kernel@vger.kernel.org, Bartosz Golaszewski , Bartosz Golaszewski , linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-leds@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1749501538; l=2169; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=/FW1uODFNygTPBiads/Cgva/fZBdnCPVHS77URlMjjc=; b=XMIA2t76cWY8q3SbUJtzN8v1jQ4AwXiPpkwDqG5ui1Cd4AyjqNi3x12hCFUhxnv95kyToir+s tiAJIto8fDLApMRKWxsys9+vfQBWRGMaKFmhqy59sHuLny/dl0fQBvt X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Even if it's not critical, the avoidance of checking the error code from devm_mutex_init() call today diminishes the point of using the devm variant of it. Tomorrow it may even leak something. Enforce all callers checking the return value through the compiler. As devm_mutex_init() itself is a macro, it can not be annotated directly. Annotate __devm_mutex_init() instead. Unfortunately __must_check/warn_unused_result don't propagate through statement expression. So move the statement expression into the argument list of the call to __devm_mutex_init() through a helper macro. Signed-off-by: Thomas Weißschuh Reviewed-by: Andy Shevchenko Reviewed-by: Bartosz Golaszewski --- include/linux/mutex.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index a039fa8c17807c700d3b61193feac0418cad1243..00afd341d293ddfcc0a427b576efdce044955e38 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -126,11 +126,11 @@ do { \ #ifdef CONFIG_DEBUG_MUTEXES -int __devm_mutex_init(struct device *dev, struct mutex *lock); +int __must_check __devm_mutex_init(struct device *dev, struct mutex *lock); #else -static inline int __devm_mutex_init(struct device *dev, struct mutex *lock) +static inline int __must_check __devm_mutex_init(struct device *dev, struct mutex *lock) { /* * When CONFIG_DEBUG_MUTEXES is off mutex_destroy() is just a nop so @@ -141,14 +141,17 @@ static inline int __devm_mutex_init(struct device *dev, struct mutex *lock) #endif -#define devm_mutex_init(dev, mutex) \ +#define __mutex_init_ret(mutex) \ ({ \ typeof(mutex) mutex_ = (mutex); \ \ mutex_init(mutex_); \ - __devm_mutex_init(dev, mutex_); \ + mutex_; \ }) +#define devm_mutex_init(dev, mutex) \ + __devm_mutex_init(dev, __mutex_init_ret(mutex)) + /* * See kernel/locking/mutex.c for detailed documentation of these APIs. * Also see Documentation/locking/mutex-design.rst.