Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2379384lqp; Sun, 24 Mar 2024 16:47:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxHumAWKzNISY7X0mLU/3aPKr0+GLrKS8g+NbjckipbGTXiHRWS80WlZHgSn4q+TT3y9SI24lih5NpwAJeUfjcLl7qM4in+U0u0/OeAA== X-Google-Smtp-Source: AGHT+IHBrEWYavfo52PLr+dyOE0zZZ72gho9HPK0Y9XViWP6Zp9EJnK+RGD8T40glEC/ZGDUdsS6 X-Received: by 2002:a50:8d14:0:b0:568:a752:5fb3 with SMTP id s20-20020a508d14000000b00568a7525fb3mr5089692eds.15.1711324076952; Sun, 24 Mar 2024 16:47:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324076; cv=pass; d=google.com; s=arc-20160816; b=yPTFBCfBkjWZi9PKMu1h86OW3ZWixL05pzGmp4T6AgmWL6jCw+bYVk+fSu9XHJC+Pm gU6sYPgciUJlPgLdtdoEuiG42f8OhCoJFShGSpw2pUVf8b3W4yV0pStUAVErTP9GmnFS wS7QMBak2J9VNn3yiYzuVoBpx4P102EYTJUTc+bOmTaFrwJ29a2nN9ypC4/uSOFUeuvi RXSVW8v/XbrlNGylMQ9S5KdYNMQhm7xIe6LjTWPDsPY2Oqzh52etdLqYaLm5dw+Fd55U cRnXwnhZTk3v35+hHVScloIzJaGxMFYH+4FsBFt41R/k3n81y5u/rxL60qSYJBDHwVf9 YG5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9Mi3184zFNKSMvBVsGMaiqXFX+Oa3KkKPTjaKuIboeo=; fh=H+bVRQQMk9WXvl5b8gMO92wjcXHLPJ3DH9PEjJsLq40=; b=iEpPQUNhxWDmXugxGoFYZiLc+kbepTR29AQpbOHoJS/Up30nqJcMXpZXHsU3kKUl9X eVb3FeuHNpMALVy6/YTy8OYZE9rK9beVA3h1Q2VPzB8H/2irRAB2PG4q2Q5lbQilv6uT Gw9pHNDt9RSAEE2wDIGWuNkcPvo2xHjvYSjiaVWEUv04mvtp1qjqDyxHNdKTWuLo+Lmv N1wN6nk2M6u2eN77zKm6Gn0zcs2BYPeWqDX6bwm50JL6AEBTeDBTZadS351y3/QNIu9o 2TzhQPMQ8XJyTl0iK9J8R8mHR30EHCL9qZa27ROIozZ2GCOCCroG9D1oAurpi4Zuffpr FF0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEzgkEFI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113220-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c13-20020a05640227cd00b0056bcec9c83fsi2172522ede.77.2024.03.24.16.47.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:47:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEzgkEFI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113220-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113220-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AD7491F21C32 for ; Sun, 24 Mar 2024 23:47:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EC79180B9F; Sun, 24 Mar 2024 22:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dEzgkEFI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A0FC180B7C; Sun, 24 Mar 2024 22:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320021; cv=none; b=PYtaho4skRQi2ShBiLjRo0UxanJClRnYn4ahbVx5IsqEXsSHOmdNI7GFAgpfe9tyTtRF6/Mdms81iffTKyLk9I04S8paWG0X8Wn0urV/8cSkzwLyZVS6eLdvMbExT39C+e7axW7g1BR/ugvgD547fuQ1LxjvpzG6i+QJBgmOliw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320021; c=relaxed/simple; bh=FAT2yniJKJbWTQWBE0dDoAbysmicJfUvGas2RFGQpZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NDEbOX8PA+jbLblH/ZK/+8h0Nn2lJgKeRxvdKx2thZBvTxYkavWUQlhxICFEoenzQTJ6Ban8nGZSjM1vDp3c6tZkDjzfgcaKs7q1T/nV4/JeZ5ooHyAfDe0wHLAG9ZY37V+dmXgGPWumVq97TrNXqjU7AdcuNamrBAKtMvKEq5E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dEzgkEFI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC6A5C43399; Sun, 24 Mar 2024 22:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320021; bh=FAT2yniJKJbWTQWBE0dDoAbysmicJfUvGas2RFGQpZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dEzgkEFILlTXNzq4zNgBuXXudyxlhgzMYEERqPIeE/D6Vw8v435PIQzB4qCPFquPd zqJJQHPFhjzgWa1Asm8deB+3EbQLHe5gA41IopKDTMzKl7gmRVeV3lxFAwKr9QlQ2l jUyRlLd81Tk4euVWWgKcuw2kLgucWqX1nBJXR8aTzM5HtTK4l+pb5Q8aT/SDf1i/pp NGXSaF0IfJ3zqNDhMPaXf03G4DtTq0rSXJXOoC6zXL4DY0GPeNYDMpiPu80fHjJYtU 7SodCQBAZQkDwqTWPKzmCes2MTJZbWAKuR4i0gPmBci1/LRX5dOVGH5bZbr4mXhK9w L3YQN3fbqWEbg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jiri Pirko , Rahul Rameshbabu , "David S . Miller" , Sasha Levin Subject: [PATCH 6.8 329/715] dpll: fix dpll_xa_ref_*_del() for multiple registrations Date: Sun, 24 Mar 2024 18:28:28 -0400 Message-ID: <20240324223455.1342824-330-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jiri Pirko [ Upstream commit b446631f355ece73b13c311dd712c47381a23172 ] Currently, if there are multiple registrations of the same pin on the same dpll device, following warnings are observed: WARNING: CPU: 5 PID: 2212 at drivers/dpll/dpll_core.c:143 dpll_xa_ref_pin_del.isra.0+0x21e/0x230 WARNING: CPU: 5 PID: 2212 at drivers/dpll/dpll_core.c:223 __dpll_pin_unregister+0x2b3/0x2c0 The problem is, that in both dpll_xa_ref_dpll_del() and dpll_xa_ref_pin_del() registration is only removed from list in case the reference count drops to zero. That is wrong, the registration has to be removed always. To fix this, remove the registration from the list and free it unconditionally, instead of doing it only when the ref reference counter reaches zero. Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions") Signed-off-by: Jiri Pirko Reviewed-by: Rahul Rameshbabu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/dpll/dpll_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index 7f686d179fc93..c751a87c7a8e6 100644 --- a/drivers/dpll/dpll_core.c +++ b/drivers/dpll/dpll_core.c @@ -129,9 +129,9 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin, reg = dpll_pin_registration_find(ref, ops, priv); if (WARN_ON(!reg)) return -EINVAL; + list_del(®->list); + kfree(reg); if (refcount_dec_and_test(&ref->refcount)) { - list_del(®->list); - kfree(reg); xa_erase(xa_pins, i); WARN_ON(!list_empty(&ref->registration_list)); kfree(ref); @@ -209,9 +209,9 @@ dpll_xa_ref_dpll_del(struct xarray *xa_dplls, struct dpll_device *dpll, reg = dpll_pin_registration_find(ref, ops, priv); if (WARN_ON(!reg)) return; + list_del(®->list); + kfree(reg); if (refcount_dec_and_test(&ref->refcount)) { - list_del(®->list); - kfree(reg); xa_erase(xa_dplls, i); WARN_ON(!list_empty(&ref->registration_list)); kfree(ref); -- 2.43.0