All of lore.kernel.org
 help / color / mirror / Atom feed
From: void0red <void0red@gmail.com>
To: linux@roeck-us.net
Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org, mezin.alexander@gmail.com,
	void0red@gmail.com
Subject: [PATCH v2 2/2] hwmon: nzxt-smart2: add a check of devm_add_action in nzxt_smart2_hid_probe
Date: Mon, 27 Feb 2023 11:09:13 +0800	[thread overview]
Message-ID: <20230227030913.893004-2-void0red@gmail.com> (raw)
In-Reply-To: <20230227030913.893004-1-void0red@gmail.com>

From: Kang Chen <void0red@gmail.com>

devm_add_action may fails, check it and return early.

Signed-off-by: Kang Chen <void0red@gmail.com>
---
v2 -> v1: split the patch

 drivers/hwmon/nzxt-smart2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c
index 2b93ba896..725974cb3 100644
--- a/drivers/hwmon/nzxt-smart2.c
+++ b/drivers/hwmon/nzxt-smart2.c
@@ -737,8 +737,10 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev,
 	init_waitqueue_head(&drvdata->wq);
 
 	mutex_init(&drvdata->mutex);
-	devm_add_action(&hdev->dev, (void (*)(void *))mutex_destroy,
+	ret = devm_add_action(&hdev->dev, (void (*)(void *))mutex_destroy,
 			&drvdata->mutex);
+	if (ret)
+		return ret;
 
 	ret = hid_parse(hdev);
 	if (ret)
-- 
2.34.1


  reply	other threads:[~2023-02-27  3:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27  2:17 [PATCH] hwmon: add a check of devm_add_action Kang Chen
2023-02-27  2:36 ` Guenter Roeck
2023-02-27  3:09   ` [PATCH v2 1/2] hwmon: g762: add a check of devm_add_action in g762_of_clock_enable void0red
2023-02-27  3:09     ` void0red [this message]
2023-02-27  4:21       ` [PATCH v2 2/2] hwmon: nzxt-smart2: add a check of devm_add_action in nzxt_smart2_hid_probe Guenter Roeck
2023-02-27  9:15         ` [PATCH v3] hwmon: nzxt-smart2: handle failure " void0red
2023-03-10 16:42           ` Guenter Roeck
2023-03-10 16:42     ` [PATCH v2 1/2] hwmon: g762: add a check of devm_add_action in g762_of_clock_enable Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230227030913.893004-2-void0red@gmail.com \
    --to=void0red@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mezin.alexander@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.