From patchwork Mon Feb 27 03:09:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: void0red X-Patchwork-Id: 13152620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D3ECC6FA8E for ; Mon, 27 Feb 2023 03:09:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbjB0DJU (ORCPT ); Sun, 26 Feb 2023 22:09:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbjB0DJT (ORCPT ); Sun, 26 Feb 2023 22:09:19 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 157FB6A50; Sun, 26 Feb 2023 19:09:19 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id u5so1908944plq.7; Sun, 26 Feb 2023 19:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1U6MZpaD1EOJajQO4fgDPUHTzMf+D4q3s0m/2f40QEo=; b=JIDUckAkqW8btXTq/k2qg++a2aoYsu/HER3CRmNV51TrL0fdm5k962NCVZJUZ6gTcQ FYPjC5bf6Y2Et8uzioTwqfOCTY7RVWKmd6A490AU+XmzpZ27sXAn1Dadzl4Y2RlnET5n GzejZtZOPM+aEQC5ICUKjsm0emC0gzvN6rmhvSqucDhiqwI4rrFXQ7lpsnRKpcN3BaMx 2f9OLGwGxE+L1l+0ahfotkN/nwLfR9TmGZZc6DthAurxQDrp1T/qpNdT0MQ9jmLfZWau wX9s+joc4Ft9L6Wc9ERU0hlkXkXUHCLTIspSvV7yF9zAq14z9gQ2m16bK8T5pLmVQhip Tpmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1U6MZpaD1EOJajQO4fgDPUHTzMf+D4q3s0m/2f40QEo=; b=M5faDXC8eF3FhkdeXp7cmFgAJtmS8goFO3GY6Rhait8WIFery6+X5z4SWEb4Ny9wUd WUfDy32XpmQTZGa1KV86C7lS8BnT+0SllMJ0BRlVUzpYjX7HCJyYWuCqVgbPXBAtsUk5 pDLasfLm8tztTWfGap/jggc57mENnNjOvl4Ink8mxyuwLtAzSm8P5HTIANTzI0f4z2HU sxn0EFyCdqddCz1126RVFQLSL2OOYo27GXPVdnniy7UApKu7X4tVjdPWaDwq1b9mMj5D jnKJt9f7ms0wE/HCNhHkcPOSmvxOYhUUSzXA1Ip7Qh6lleLiYrTpS8tTxu8l+Awofm71 RBJw== X-Gm-Message-State: AO0yUKVrO1acoNA1j6DPsnA9qOQ5hBzs3OE7J/M4U/U7EGCkot0kWPeG +jq9PsFdcxaWkmrpZOpumKg= X-Google-Smtp-Source: AK7set+tuqTlwQTaAQONHe37YHToLq/9wufM+u3StxeeSU3JQZh8pf/sPH+1TUUROHW9ndMLuLffrA== X-Received: by 2002:a17:90b:4a03:b0:236:6dea:87b4 with SMTP id kk3-20020a17090b4a0300b002366dea87b4mr24893121pjb.39.1677467358458; Sun, 26 Feb 2023 19:09:18 -0800 (PST) Received: from localhost.localdomain ([103.116.245.58]) by smtp.gmail.com with ESMTPSA id r6-20020a17090a5c8600b00234a2f6d9c0sm3189852pji.57.2023.02.26.19.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 19:09:17 -0800 (PST) From: void0red 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 1/2] hwmon: g762: add a check of devm_add_action in g762_of_clock_enable Date: Mon, 27 Feb 2023 11:09:12 +0800 Message-Id: <20230227030913.893004-1-void0red@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <42cdd5e4-c9da-b31a-0ffd-76846757645c@roeck-us.net> References: <42cdd5e4-c9da-b31a-0ffd-76846757645c@roeck-us.net> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Kang Chen devm_add_action may fails, check it and do the cleanup. Signed-off-by: Kang Chen --- v2 -> v1: split the patch drivers/hwmon/g762.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c index 64a0599b2..e2c3c34f0 100644 --- a/drivers/hwmon/g762.c +++ b/drivers/hwmon/g762.c @@ -620,7 +620,12 @@ static int g762_of_clock_enable(struct i2c_client *client) data = i2c_get_clientdata(client); data->clk = clk; - devm_add_action(&client->dev, g762_of_clock_disable, data); + ret = devm_add_action(&client->dev, g762_of_clock_disable, data); + if (ret) { + dev_err(&client->dev, "failed to add disable clock action\n"); + goto clk_unprep; + } + return 0; clk_unprep: From patchwork Mon Feb 27 03:09:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: void0red X-Patchwork-Id: 13152621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 500C0C64ED6 for ; Mon, 27 Feb 2023 03:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229745AbjB0DJ2 (ORCPT ); Sun, 26 Feb 2023 22:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230384AbjB0DJZ (ORCPT ); Sun, 26 Feb 2023 22:09:25 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E469E041; Sun, 26 Feb 2023 19:09:24 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id i10so5293786plr.9; Sun, 26 Feb 2023 19:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Trp/vR8DThjFf6YmscyB4zrOKQwpzckPU820EYJvgFw=; b=YMadYORhS31M8ogyNVO7bO7r/6p/QlHgeLSH6n3UO6SWjRBVz21C5gbxIaNglSM57z 6KjXLtVmt8QAgokEaLNNjDQIl3YpBNrj+FP1aW55JuP1XOWS7XMMNMT6YuKhzAZeqDDL TC8VlWdAAPY9p1C84pAB5/jXMiWVgNObHJCKtpqygWkEczd5i4JlaBDpq5l2uSvYZxaX GSx4P4AiRZKabBxWeU0QCnKncw1Yrrw+/1sglxJrVWQwZGc/Hbxtb5LiiEm65clDuq0U 0tn+Q7F4QjOY1X40IJGCZV/DyjOPjaXJLPsx8HrjcFsRkHo7j2yId4wv7IQIIbmDEg9u Ufrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Trp/vR8DThjFf6YmscyB4zrOKQwpzckPU820EYJvgFw=; b=N3KUKJy/7LaUlbcYADypqPiq1MjvEfbr35nrFpJZaNLp9OMj0x8j/s5t2Sn0WZTMWH LsbiahGzFUp/6z0kNFB48ho0PEMvZlm8XB2JNQFaXVPgGEuT8mrf4Jt9ghkZc9rvrVIc BvmNsz9WvU8pOKBx93ZSArpnTdEzHeYNH3A9PsbAKe8sYuyZ7kX0rYhFGbRxeYP2lXz/ X6S91zeJttf/dKOVgf2PzGjhHiq62Lgs5XU5xYURFh24sFRW4Cb9LNbtoLN6GnsxDR9n ZmGfb/ADOSIR74f7mF1M6TdWAqnW1oYU12AmemYSFiGPzr5vVA1sdJgtCzyFLoP5qRLm qDrw== X-Gm-Message-State: AO0yUKWPAkL+wamA4YdR22IK5zDtNhTYnJfYCsG02esJvyGL6C6QHN/L OTsWvfgVW8uzfMoS9egOXIk= X-Google-Smtp-Source: AK7set+oazlLkoiSLcwaQPrF8z4qwasmJHhVZ8eN1sDjWR6mjMITdO/fOxgSQK19iTq9gU/5ChOxiQ== X-Received: by 2002:a17:90b:4d0a:b0:237:c04b:7365 with SMTP id mw10-20020a17090b4d0a00b00237c04b7365mr7037685pjb.7.1677467364093; Sun, 26 Feb 2023 19:09:24 -0800 (PST) Received: from localhost.localdomain ([103.116.245.58]) by smtp.gmail.com with ESMTPSA id r6-20020a17090a5c8600b00234a2f6d9c0sm3189852pji.57.2023.02.26.19.09.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 19:09:23 -0800 (PST) From: void0red 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 Message-Id: <20230227030913.893004-2-void0red@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227030913.893004-1-void0red@gmail.com> References: <42cdd5e4-c9da-b31a-0ffd-76846757645c@roeck-us.net> <20230227030913.893004-1-void0red@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Kang Chen devm_add_action may fails, check it and return early. Signed-off-by: Kang Chen --- 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)