From mboxrd@z Thu Jan 1 00:00:00 1970 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 ECBEFC636D3 for ; Wed, 1 Feb 2023 11:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231995AbjBALQ6 (ORCPT ); Wed, 1 Feb 2023 06:16:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232287AbjBALQ4 (ORCPT ); Wed, 1 Feb 2023 06:16:56 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B9ED4941D for ; Wed, 1 Feb 2023 03:16:55 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id m2so49908852ejb.8 for ; Wed, 01 Feb 2023 03:16:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nUrDb3EKbEwP1E+cTaz4aoYhl8shzIQnqUH5alCaiS4=; b=CBZPUQGhVvP6T/uXZYCqwU9h2SJ8G56BHcnskNnJ4P0subv/PysGZm16NTqJX1rNSa G9qxcy8HOE9gDyCRrxRyRM5n2HElWKS9VoU6rRRLzNkUrYYjn18cQ+QAeZY/agndj2er Ma39+WR3sTZ86HZeCDTAe6bLAazBG7aNtTDkQ4dERuKaRm1/irT2MrLCHGvVmA6naIyO wXn6L0Un4Hw/JsoKwLHyFJCDa28qry65QnVV2J+JrVksf2q3sdiEn+AjHo2eRJd7+MpF +QRfN6Mrbva9jAyigyKP/BWMnZkT7Eyxaq7IP1XZ+cI7JT9U/L3de8S84po2NEGfML3o vyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nUrDb3EKbEwP1E+cTaz4aoYhl8shzIQnqUH5alCaiS4=; b=EnOwd4v7tZ2mQU+/Ftgz5ZKWN14gqkYTgLQacDAMZbvGS9JOK7D5PZNrRTBeLEQCNE /Sk5gNLp4XlQySkxWhbVAwralfQLHGwODEu0hfwWjK2uOKYecRsv5fDuFmwg1F/bxQgT xuR7r6U/AR3/qI9Zq+ZFjstLqh2z7/qk+Y+uHTztVrS61b9asL3Kl/qvBGTtymo/q0o5 BeCXoXUUKYvKUasR6oBqBboBSj90jGEH4uB9fq0OPxf/h6hd2qUo3+5NVy93A6px/BY3 eNzQXtY+NwUodN/0h0RhF+RpAuJPF8s0G6wu0oHtxBK7yDP3Dd67w6AQ7dC4GIK9WczJ NJQg== X-Gm-Message-State: AO0yUKWAoKA+0Ffe4gixpU1zjRRkBth9rwHjwhWx42guzTVRNM8OXKeT s9eHq+MlIa0TIA8i2lzECisO0A== X-Google-Smtp-Source: AK7set8nZ5tenjhJ1UYP/fKSzZRqpA5VSaBodwJMTzJ2q15pnSFNExgvYIEYEGfWJP3FuMhx61MO4w== X-Received: by 2002:a17:906:ae5a:b0:878:81d7:9f6f with SMTP id lf26-20020a170906ae5a00b0087881d79f6fmr1945277ejb.67.1675250213863; Wed, 01 Feb 2023 03:16:53 -0800 (PST) Received: from [192.168.1.101] (abyl20.neoplus.adsl.tpnet.pl. [83.9.31.20]) by smtp.gmail.com with ESMTPSA id w5-20020a1709061f0500b0086a2e31d1c1sm9832739ejj.28.2023.02.01.03.16.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Feb 2023 03:16:53 -0800 (PST) Message-ID: <9b7813d0-ec4e-a4a1-168f-de0797bcdf64@linaro.org> Date: Wed, 1 Feb 2023 12:16:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH 02/23] interconnect: fix icc_provider_del() error handling Content-Language: en-US To: Johan Hovold , Georgi Djakov Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Andy Gross , Bjorn Andersson , Sylwester Nawrocki , =?UTF-8?B?QXJ0dXIgxZp3aWdvxYQ=?= , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20230201101559.15529-1-johan+linaro@kernel.org> <20230201101559.15529-3-johan+linaro@kernel.org> From: Konrad Dybcio In-Reply-To: <20230201101559.15529-3-johan+linaro@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On 1.02.2023 11:15, Johan Hovold wrote: > The interconnect framework currently expects that providers are only > removed when there are no users and after all nodes have been removed. > > There is currently nothing that guarantees this to be the case and the > framework does not do any reference counting, but refusing to remove the > provider is never correct as that would leave a dangling pointer to a > resource that is about to be released in the global provider list (e.g. > accessible through debugfs). > > Replace the current sanity checks with WARN_ON() so that the provider is > always removed. I spent a considerable amount of time scratching my head what WARN_ON has to do with removing list items.. I suppose "don't return early and replace pr_warn with WARN_ON" would have been clearer, but maybe that's just me in the morning.. > > Fixes: 11f1ceca7031 ("interconnect: Add generic on-chip interconnect API") > Cc: stable@vger.kernel.org # 5.1: 680f8666baf6: interconnect: Make icc_provider_del() return void > Signed-off-by: Johan Hovold > --- Reviewed-by: Konrad Dybcio Konrad > drivers/interconnect/core.c | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > > diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c > index dc61620a0191..43c5c8503ee8 100644 > --- a/drivers/interconnect/core.c > +++ b/drivers/interconnect/core.c > @@ -1062,18 +1062,8 @@ EXPORT_SYMBOL_GPL(icc_provider_add); > void icc_provider_del(struct icc_provider *provider) > { > mutex_lock(&icc_lock); > - if (provider->users) { > - pr_warn("interconnect provider still has %d users\n", > - provider->users); > - mutex_unlock(&icc_lock); > - return; > - } > - > - if (!list_empty(&provider->nodes)) { > - pr_warn("interconnect provider still has nodes\n"); > - mutex_unlock(&icc_lock); > - return; > - } > + WARN_ON(provider->users); > + WARN_ON(!list_empty(&provider->nodes)); > > list_del(&provider->provider_list); > mutex_unlock(&icc_lock); From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0899CC636D4 for ; Wed, 1 Feb 2023 11:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m13Jbjn88Sd5sId1AOZVEloEnh3HbE6J+1n2X1gldrI=; b=1sKSwpRm1gLP5W +tst0lg917QbBJBJz19dpGXPfGdFSg+FyazZbOXxcK1cgg4tBBBS1RYDhU3eUyErLfyHbh8cndYUK vPJoHwnTRRFtFtepHRQ8fZA5ehAMaWiWDhGvI6IUaP6luwAaMAOEI+AGqwDD7OBq80GLAymImQuW/ Kory9xT9HmhI0QHrW0j++DyXvb/8Em0mKlqbxd1QP4xt+PhCK1kM/AHlWk00n7WSvT9SyhnEBJawp ZbfriSZKyPqLvmsMyVXU3aqCo8FcZOmSHBtfFjj9kNveQpjvJdKk0Gn+z0VIJeRifniaAGDwV6aOJ ucJVgqtQNYyDliM98tnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNB6q-00BREz-ER; Wed, 01 Feb 2023 11:17:00 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNB6l-00BRCP-Gi for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 11:16:57 +0000 Received: by mail-ej1-x62d.google.com with SMTP id qw12so34449524ejc.2 for ; Wed, 01 Feb 2023 03:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nUrDb3EKbEwP1E+cTaz4aoYhl8shzIQnqUH5alCaiS4=; b=CBZPUQGhVvP6T/uXZYCqwU9h2SJ8G56BHcnskNnJ4P0subv/PysGZm16NTqJX1rNSa G9qxcy8HOE9gDyCRrxRyRM5n2HElWKS9VoU6rRRLzNkUrYYjn18cQ+QAeZY/agndj2er Ma39+WR3sTZ86HZeCDTAe6bLAazBG7aNtTDkQ4dERuKaRm1/irT2MrLCHGvVmA6naIyO wXn6L0Un4Hw/JsoKwLHyFJCDa28qry65QnVV2J+JrVksf2q3sdiEn+AjHo2eRJd7+MpF +QRfN6Mrbva9jAyigyKP/BWMnZkT7Eyxaq7IP1XZ+cI7JT9U/L3de8S84po2NEGfML3o vyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nUrDb3EKbEwP1E+cTaz4aoYhl8shzIQnqUH5alCaiS4=; b=LLdIFtKA5tSTNPXXdsLhjj1nFNtaLkEDa38zcZwCxfxcUTucO1fDyTIZ5NnkcYWtGE HMN2zOVd6uKW4dPN/DWI2kLjG1tSEHCbfq6fL7yk5Cpyi8a9/7qqc69jHp9fbIyOMCnQ RsgJwQbx+F2CFWQcOe3StVR8j/AJcX+0viVxXz/a8+ewWbEP3UDdPt9u0FbPl4nFj2y/ mfH3HTAqM8Tnj1Q/RDvHfAbcCrUqYpkxdzHTzk1rRCb5UdbgrRUJT9qDUluGuFhHZMlW +Rd4rZuVFq7PI6++B7+gPTGnMYpflUrQGLPMWzcjVW7v5zDvEXnpV0shakEyNITbGW2u Myqw== X-Gm-Message-State: AO0yUKXGFXrpMizfeh5jqpwJx3h3jTLjhUjxHT/nQQGvXTDZHQCQpYgv ipZDMldCkDQpN+IWHV8t1NOJeg== X-Google-Smtp-Source: AK7set8nZ5tenjhJ1UYP/fKSzZRqpA5VSaBodwJMTzJ2q15pnSFNExgvYIEYEGfWJP3FuMhx61MO4w== X-Received: by 2002:a17:906:ae5a:b0:878:81d7:9f6f with SMTP id lf26-20020a170906ae5a00b0087881d79f6fmr1945277ejb.67.1675250213863; Wed, 01 Feb 2023 03:16:53 -0800 (PST) Received: from [192.168.1.101] (abyl20.neoplus.adsl.tpnet.pl. [83.9.31.20]) by smtp.gmail.com with ESMTPSA id w5-20020a1709061f0500b0086a2e31d1c1sm9832739ejj.28.2023.02.01.03.16.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Feb 2023 03:16:53 -0800 (PST) Message-ID: <9b7813d0-ec4e-a4a1-168f-de0797bcdf64@linaro.org> Date: Wed, 1 Feb 2023 12:16:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Subject: Re: [PATCH 02/23] interconnect: fix icc_provider_del() error handling Content-Language: en-US To: Johan Hovold , Georgi Djakov Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Andy Gross , Bjorn Andersson , Sylwester Nawrocki , =?UTF-8?B?QXJ0dXIgxZp3aWdvxYQ=?= , Krzysztof Kozlowski , Alim Akhtar , Thierry Reding , Jonathan Hunter , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20230201101559.15529-1-johan+linaro@kernel.org> <20230201101559.15529-3-johan+linaro@kernel.org> From: Konrad Dybcio In-Reply-To: <20230201101559.15529-3-johan+linaro@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230201_031655_609297_1870B17E X-CRM114-Status: GOOD ( 21.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1.02.2023 11:15, Johan Hovold wrote: > The interconnect framework currently expects that providers are only > removed when there are no users and after all nodes have been removed. > > There is currently nothing that guarantees this to be the case and the > framework does not do any reference counting, but refusing to remove the > provider is never correct as that would leave a dangling pointer to a > resource that is about to be released in the global provider list (e.g. > accessible through debugfs). > > Replace the current sanity checks with WARN_ON() so that the provider is > always removed. I spent a considerable amount of time scratching my head what WARN_ON has to do with removing list items.. I suppose "don't return early and replace pr_warn with WARN_ON" would have been clearer, but maybe that's just me in the morning.. > > Fixes: 11f1ceca7031 ("interconnect: Add generic on-chip interconnect API") > Cc: stable@vger.kernel.org # 5.1: 680f8666baf6: interconnect: Make icc_provider_del() return void > Signed-off-by: Johan Hovold > --- Reviewed-by: Konrad Dybcio Konrad > drivers/interconnect/core.c | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > > diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c > index dc61620a0191..43c5c8503ee8 100644 > --- a/drivers/interconnect/core.c > +++ b/drivers/interconnect/core.c > @@ -1062,18 +1062,8 @@ EXPORT_SYMBOL_GPL(icc_provider_add); > void icc_provider_del(struct icc_provider *provider) > { > mutex_lock(&icc_lock); > - if (provider->users) { > - pr_warn("interconnect provider still has %d users\n", > - provider->users); > - mutex_unlock(&icc_lock); > - return; > - } > - > - if (!list_empty(&provider->nodes)) { > - pr_warn("interconnect provider still has nodes\n"); > - mutex_unlock(&icc_lock); > - return; > - } > + WARN_ON(provider->users); > + WARN_ON(!list_empty(&provider->nodes)); > > list_del(&provider->provider_list); > mutex_unlock(&icc_lock); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel