From patchwork Mon Nov 20 16:45:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kiryushin X-Patchwork-Id: 167270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp64129vqb; Mon, 20 Nov 2023 08:47:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMnA9GxhfSYzEvyeUhr36Krfoceb8uPQct2yMbyQb89ElE27qAMbAQ47gDAoCI38nEqeaS X-Received: by 2002:a05:6a21:3810:b0:186:555e:bc80 with SMTP id yi16-20020a056a21381000b00186555ebc80mr4625287pzb.25.1700498828869; Mon, 20 Nov 2023 08:47:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700498828; cv=none; d=google.com; s=arc-20160816; b=ltMPU6PQ7ypRO/nfc+4QvVZK6g7/vvfC2K5ZOq7vyhgC1OXx6css50iluIrS8yRAFB tQu/MkN/iExvI9+1KUm0T+99+BxzJ0ij+i7uqPqI4fRS6K+HsbbFFjS059oZQTbW4bP7 0iazTdF6EGZ7i/awBH3QfJlmEODZbbPGVM55ukJ/SclOvQS8UTa4md8n92XwptbAiJGZ 77oqLpOP5oSA1h+3LRh2tJqFZWtRh71FFSNQDpdqgFfJ/wbTEQWRNLJWvBAKE6FVrIA3 oFh3Wxuy32th70/HHd+ks5ZyD67nr3aCmCaUQ24pC/kIgtxgqgkflmB10k8JxYZ6WpqW tOfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id; bh=ghqFqrn9U/QR4fW4jkVlssNebZcTCkXyMEgzyy+txuY=; fh=2z/fVWGU8OvAlSlMY7joJHFYHAHABMKAHIzyJle+zSg=; b=If+IDh8LqUj2r2GWTFjMwvxmvqesdDm88RusOWNLqBI3earljVI79ZQQf3qcB2ZIgN 320f5XuNhZp3/EuibNQx7saENv1hS2/PoSyB6dkMm04HMavalCIHN+FzYDfEFcfs/XTA SsU3/ZqUdPCK69rsllv6kXh73EBvr7xXo4EUPqCfQNZJFDTqQh7G+SRJeuehASAmRNka +EoAcQLWbNxHPpApclNrl5ISvUiHvw+0wpGYzIx6CDYz9UrA2kJdB+zV/KQlHvJhfxwb C7ilw903rUQx59jc4WGVZdQC3Oe3aC2kLWn5x5OtcUOsDhyz9YTmqC0UQGp0F0MdEEOG +4Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cl20-20020a056a02099400b005c1b313a127si8926959pgb.660.2023.11.20.08.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 08:47:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CD7F280310C1; Mon, 20 Nov 2023 08:47:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233675AbjKTQqp (ORCPT + 27 others); Mon, 20 Nov 2023 11:46:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233990AbjKTQq0 (ORCPT ); Mon, 20 Nov 2023 11:46:26 -0500 Received: from relay163.nicmail.ru (relay163.nicmail.ru [91.189.117.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD1E8D6F; Mon, 20 Nov 2023 08:45:40 -0800 (PST) Received: from [10.28.138.152] (port=50740 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1r57Ox-0000kZ-BK; Mon, 20 Nov 2023 19:45:36 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1104.mail.hosting.nic.ru (Exim 5.55) with id 1r57Ox-002hz6-0z; Mon, 20 Nov 2023 19:45:35 +0300 Message-ID: <958b96ee-9224-4289-a3f6-b654d2b49f13@ancud.ru> Date: Mon, 20 Nov 2023 19:45:34 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Nikita Kiryushin Subject: [PATCH v2] power: reset: msm: Process register_restart_handler() error To: Andy Gross Cc: Bjorn Andersson , Konrad Dybcio , Sebastian Reichel , Stephen Boyd , Guenter Roeck , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Content-Language: en-US X-MS-Exchange-Organization-SCL: -1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 08:47:06 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783102259935883258 X-GMAIL-MSGID: 1783102259935883258 If registering restart handler fails for msm-restart result is not checked. It may be irrelevant now (as stated in comment to register_restart_handler, the function currently always returns zero), but if the behavior changes in the future, an error at registration of handler will be silently skipped. Add return error code and print error message too debug log in case of non-zero result of register_restart_handler. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 18a702e0de98 ("power: reset: use restart_notifier mechanism for msm-poweroff") Signed-off-by: Nikita Kiryushin --- v2: remove superfluous initialization, use specialized error handler for probes, set poweroff handler regardless of restart handler registration failure as Sebastian Reichel suggested. drivers/power/reset/msm-poweroff.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/power/reset/msm-poweroff.c b/drivers/power/reset/msm-poweroff.c index d96d248a6e25..0d568805e70e 100644 --- a/drivers/power/reset/msm-poweroff.c +++ b/drivers/power/reset/msm-poweroff.c @@ -35,14 +35,17 @@ static void do_msm_poweroff(void) static int msm_restart_probe(struct platform_device *pdev) { + int ret; msm_ps_hold = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(msm_ps_hold)) return PTR_ERR(msm_ps_hold); - register_restart_handler(&restart_nb); - pm_power_off = do_msm_poweroff; + ret = register_restart_handler(&restart_nb); + if (ret) + return dev_err_probe(&pdev->dev, ret, "unable to register restart handler\n"); + return 0; } -- 2.34.1