Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4150645rwe; Tue, 30 Aug 2022 05:37:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR6uvuV10plnFNfPwpICAOaCr4jdUFgGOM9b4y+BPz3M9oGITKgg8TovZTtGQ12rpSOk07aB X-Received: by 2002:aa7:d759:0:b0:447:b08b:6d00 with SMTP id a25-20020aa7d759000000b00447b08b6d00mr19613895eds.413.1661863031932; Tue, 30 Aug 2022 05:37:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661863031; cv=none; d=google.com; s=arc-20160816; b=d/GRtPgJcKXeV65VPpG7X6NfIQRv00CUJRf0q0HJwnPGrsmgAAOe5VRKBMlkGZ25lS S/WYuKfE9q+/O4TqH32sEafFDHOq/Fqs9vHTl9fJ9owOqPE1qGs6dpcD2BO8/ehgGBfO UCFuGh8f8FgctxYVlDVngcbKtmQGgYgGDZ/i8aGUs+/fh9kMmO3ISWA3DgUNWJVGD5ul zVJmJGpFYBmRF5Ar0yd1VP8/IpfnLqK3S6Wls4L1bkg56YtgLpn21K0lbcZkSjRIO7Hp HNYB2PDMUyrygjK9ZRy6cJ0Nymu0A2tm4RKQMjvEaJjQr6Jrha7Miva2N7dHE17H1RQS YmbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oACP5OJ8E262bJyD/huCTI3+4w0pfeaLTzinloHqVMQ=; b=N6GIYTQvJ7v9QtFh6h2tOblhjxHqemzGjnuAaZdlDGTfQdbfgf14G0LAlnJva7xDf8 LuR7RbWCWMh///R5paF0wLqSQVbPUPlTJ0LUcOrID8EOBNg+vA2S0JmwDDuJ1hhjJWWl V36Z7QlzUkhSQOR3sZc1lUDdKozvzALHRRKLFzWmX5AK9jnQa/DeFN6aeZ2746eIRjV3 cTWS3zcyl1lSK5Yk1zszozfG2KKTRfs/9E6AMJql81tTWJlWqipSRoYtLTDIS3rxkQMr 41L8bKXck5y/sKTx6pLP/vY6fgt0Ieu9480ZzzOL4BN+9xVu2eD8mHsXd1du0ixm+U7r HRsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DmtvEIod; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kt27-20020a170906aadb00b00734be0d7167si7780671ejb.825.2022.08.30.05.36.44; Tue, 30 Aug 2022 05:37:11 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=DmtvEIod; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbiH3MOM (ORCPT + 99 others); Tue, 30 Aug 2022 08:14:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbiH3MOH (ORCPT ); Tue, 30 Aug 2022 08:14:07 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9164E155A51 for ; Tue, 30 Aug 2022 05:14:06 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id m7so6329631lfq.8 for ; Tue, 30 Aug 2022 05:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=oACP5OJ8E262bJyD/huCTI3+4w0pfeaLTzinloHqVMQ=; b=DmtvEIodMZpn1KTPg/BtyUYkVLXGbMytdn6Cys0esmT+9iQN0XAvFe42woLBW/vtBp ZS1w+ZFLCTH5EuI1uyUgA0d49DABrExr4Q2Q0klOa2D7g8C/pHUiq/OKTgRbbqguDN1D NCngdCsdD0KZCSIWIrET1AM4LV8HLExbZoxXgxG1+6NOaCFHmTnom4uVmGQJpskH5fJv nsvkMj/ScQUK6BKiye/dXX20Zu0TFdbUNO1AHhjektm683zwSI5abtOqnt7BC1Wq6VL0 qjmNzei4jAEl3Y8QMWf15lp97r3x9KkpHlCZYoMaaxz3tKJVq0WJbnukJYwOCFZxfAfr F1Dw== 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; bh=oACP5OJ8E262bJyD/huCTI3+4w0pfeaLTzinloHqVMQ=; b=i4HKnbJ6rdrJ0V4BKK4NPPtSCObNcTqA4y2wTnvsTACNPRwivHmbgZ/W9qt0NzVcsG aRTlWDBkTB6xWj4URuD1i8DVZnkdulR07aIxNsjh7O4DXrHaI4IaktecNTAQwptbD31H FCUBtC1jzX20KBVtzZEJFhgpOorc7mBULFgj98wNniaEQXAv1WNgyg34mNk4dl/8e69j TEL6biSL1np2MU27VAYoVq9LJseSx11IPsUOT2d408lQmbZaF3JOxbsd0fRs9zg4FTkA 0FlR1QG1+vf0rVK9Zv89ErxVgN+TZV7x0tUHPOoQjAB8RLSVnMgRVJuykWkL2stgmnkr bu5Q== X-Gm-Message-State: ACgBeo2B/+Dy74SqRDiSeYV7Ba70W7FTj9TWeVWfF94d1ahpuUip3Ii0 InVfEA8x/Nqd/49GVGACjBWfP/fQ8VNhrIxNpM4= X-Received: by 2002:a05:6512:38b2:b0:493:9a:ac2e with SMTP id o18-20020a05651238b200b00493009aac2emr7333228lft.126.1661861644793; Tue, 30 Aug 2022 05:14:04 -0700 (PDT) Received: from krzk-bin.. (balticom-73-99-134.balticom.lv. [109.73.99.134]) by smtp.gmail.com with ESMTPSA id e14-20020a2e984e000000b0025e57b40009sm1742436ljj.89.2022.08.30.05.14.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 05:14:04 -0700 (PDT) From: Krzysztof Kozlowski To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Srinivas Kandagatla , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , stable@vger.kernel.org Subject: [PATCH 2/3] slimbus: qcom-ngd: cleanup in probe error path Date: Tue, 30 Aug 2022 15:13:58 +0300 Message-Id: <20220830121359.634344-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220830121359.634344-1-krzysztof.kozlowski@linaro.org> References: <20220830121359.634344-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Add proper error path in probe() to cleanup resources previously acquired/allocated: notifier callback qcom_slim_ngd_ssr_notify already registered WARNING: CPU: 6 PID: 70 at kernel/notifier.c:28 notifier_chain_register+0x5c/0x90 Modules linked in: CPU: 6 PID: 70 Comm: kworker/u16:1 Not tainted 6.0.0-rc3-next-20220830 #380 Call trace: notifier_chain_register+0x5c/0x90 srcu_notifier_chain_register+0x44/0x90 qcom_register_ssr_notifier+0x38/0x4c qcom_slim_ngd_ctrl_probe+0xd8/0x400 platform_probe+0x6c/0xe0 really_probe+0xbc/0x2d4 __driver_probe_device+0x78/0xe0 driver_probe_device+0x3c/0x12c __device_attach_driver+0xb8/0x120 bus_for_each_drv+0x78/0xd0 __device_attach+0xa8/0x1c0 device_initial_probe+0x18/0x24 bus_probe_device+0xa0/0xac deferred_probe_work_func+0x88/0xc0 process_one_work+0x1d4/0x320 worker_thread+0x2cc/0x44c kthread+0x110/0x114 ret_from_fork+0x10/0x20 Cc: Fixes: e1ae85e1830e ("slimbus: qcom-ngd-ctrl: add Protection Domain Restart Support") Signed-off-by: Krzysztof Kozlowski --- drivers/slimbus/qcom-ngd-ctrl.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 6fe6abb86061..bacc6af1d51e 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -1576,18 +1576,27 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) ctrl->pdr = pdr_handle_alloc(slim_pd_status, ctrl); if (IS_ERR(ctrl->pdr)) { dev_err(dev, "Failed to init PDR handle\n"); - return PTR_ERR(ctrl->pdr); + ret = PTR_ERR(ctrl->pdr); + goto err_pdr_alloc; } pds = pdr_add_lookup(ctrl->pdr, "avs/audio", "msm/adsp/audio_pd"); if (IS_ERR(pds) && PTR_ERR(pds) != -EALREADY) { ret = PTR_ERR(pds); dev_err(dev, "pdr add lookup failed: %d\n", ret); - return PTR_ERR(pds); + goto err_pdr_lookup; } platform_driver_register(&qcom_slim_ngd_driver); return of_qcom_slim_ngd_register(dev, ctrl); + +err_pdr_alloc: + qcom_unregister_ssr_notifier(ctrl->notifier, &ctrl->nb); + +err_pdr_lookup: + pdr_handle_release(ctrl->pdr); + + return ret; } static int qcom_slim_ngd_ctrl_remove(struct platform_device *pdev) -- 2.34.1