From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1846742F6FC for ; Wed, 8 Jul 2026 11:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783508504; cv=none; b=Ai0YXfNRX+VzMfW9pj3pt+rwK4DKynKvErPC35qxkADJpKo6D+xdccpGsgJD9JweScxpyj0ZmtorS7B0CJW9y9wCvsTePwgi2h68DWG82vQ7CJHqCksPZFAF5IAAFyAzqFY5J1ocov3PbEyJ1dVWQQLuv8MjoamMo2Fu7TQwdeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783508504; c=relaxed/simple; bh=YTaaWjYSXf37/O64vVOJlMn6uJ3wzTPz6MyKhGkDpCc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=gh/R1lX0GoP8i3V/iBTnXItWo05adU+uzyFWplk29zyFXbJqjHfDcleh2xFIYJKrz8SWgsC1CPnBiDVpHf/icRZC/RkaIQUpPz++iZkeAojsY4G1z/fODnkRDD9kwWsjHLfmhgNm2ev+Jjxql/qQulhKNgQbMAD/scicGkdsaSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FRw3o+AT; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FRw3o+AT" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-845c92bc464so307069b3a.2 for ; Wed, 08 Jul 2026 04:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783508501; x=1784113301; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=jZbH5XcFqp9SWE5IMtoeIvw8DFbEAEc+msM3hD5f1Yc=; b=FRw3o+AT1kmL95FExRgF3VcvUS1cLKt0DNysQBIv6Bne85Dt8uMPVII0A4k4tiYTOC GO0WkwPAO8c6eNqHSN+Wf489nZcgd8Jrfn/TcDxGdsYUj0C7KwYGjT1S+NRsBAJSCfz9 b8jTAESoIj1sWrTQ2lJAhQ21EDg82kiRXLzQ6Pl21W8VRxEPBP7EfufZyrTLMmTHXrku FrcDIhWhpI6Wg/+3363BICnxhM1G3AyOiOKagpH8+BaSP3qxW/85zXGPd9G5KBvJqBBJ zU9XrElGo+O2HQqiTYd218QguyqPChoxetDlXjzw1V5A7vLBNkA2IvBhVo15sKm64RhA jKCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783508501; x=1784113301; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jZbH5XcFqp9SWE5IMtoeIvw8DFbEAEc+msM3hD5f1Yc=; b=GcytYxDe+itxa3iGcZ100fBaE1mVJSDY2Y8BaEZ+M3vOuW6XgMu4HWWmlj/rvdvbRc /2YFwqMJu5XqOVyZHoGeZT2rqeBOAARe/cEI/uhHZ5+rwHY3oKn0TYgNQh806cZ+pYqU mQ2NUwz7+S99TMt3pJoq80GIsaH+XCQAeHcj3nL6d3P8vki4retIaG3VU6AaUA3DIT45 oTv+MO/F68zdVdfXwf2MMitYYAVj4Ij80ffIC/1jnIGhh7ULZ63t0ff37boWh6aWEL5d G+RYGCDzM4ICoZiB5gQpL/NTjlOH4G5d5Hrcvmz3IEqOWNS2IQWR01DRHEKAChul8pT+ oTMg== X-Forwarded-Encrypted: i=1; AHgh+RrYihL4H76p/FVBEthHvZo2xuk/rfqm1TbMTLyIiFrsrcyVfaC4B8qxs2yL62aUMHvQB/xNA2h96VYkBgk=@vger.kernel.org X-Gm-Message-State: AOJu0YyYIXVU5dyXiKD2JbTrSRG8ZXB2C0oJvQEBH4Ow7+F11mupYfdf UEb6+juGSQB/aUni5gusCowAtbur1pvj4+hId3P+QrEHhpJdn1sL+oRc X-Gm-Gg: AfdE7cnnc/TnjapdasE33eTPpwbZJVtwAJDYyxME1EMa3BUNYX+zdAgnvipaJqFhIsx hRD1EpDBatTFikzOMnOqkY9K3Sra/vqOix2A8KuO4zMYUX1gSJ/bz2RJZF4aBwO6XI5xH5sras4 WWDGLYZucK+YAJTA9QWA7coe87tmMCSyNbpMoyb/Kuo7OjYviwF5eXYZSuOPyFp6UmWhQfONxWG gzSqt/Ar498Fh9CAuI7nXnwoKWrDd2LLddZ8lv8s2aCjNL5hhGi71ErhPTv44kw6/c4eQtU6Ilf Q920nlmLXk5W6QvJ870FhAhFuZBXSUUtnLJnwc/Gz+6oZg8dRuVQGgskIQ+RtJPGxDfeF+MJrhX VOrIBWoZkr7b7PoDDdJKAOG2C5VHM82W3Ey1RYfpRkaxPWxiXcnRHTGFFekQBOC1H9c8lT0QM4e ygIUaDkOYOzza5Jg== X-Received: by 2002:a05:6a00:92a8:b0:847:438f:500c with SMTP id d2e1a72fcca58-8484368e384mr1919809b3a.60.1783508500785; Wed, 08 Jul 2026 04:01:40 -0700 (PDT) Received: from lgs.. ([152.32.133.247]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8484c32ee5esm259488b3a.29.2026.07.08.04.01.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 04:01:40 -0700 (PDT) From: Guangshuo Li To: "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Guangshuo Li Subject: [PATCH] cpufreq: nforce2: put PCI device on driver register failure Date: Wed, 8 Jul 2026 19:01:31 +0800 Message-ID: <20260708110131.748268-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit nforce2_detect_chipset() stores a PCI device returned by pci_get_subsys() in the global nforce2_dev pointer. That reference is kept for the lifetime of the loaded module and is released from nforce2_exit(). However, nforce2_init() gets the PCI device reference before registering the cpufreq driver. If cpufreq_register_driver() fails, nforce2_init() returns an error and the module exit path is not run. The reference held in nforce2_dev is then leaked. Drop the PCI device reference before returning from the registration failure path. Clear the global pointer as well so the failed initialization leaves no stale reference behind. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Guangshuo Li --- drivers/cpufreq/cpufreq-nforce2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index 831102522ad6..5a101c69c47a 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c @@ -409,6 +409,8 @@ static int nforce2_detect_chipset(void) */ static int __init nforce2_init(void) { + int ret; + /* TODO: do we need to detect the processor? */ /* detect chipset */ @@ -417,7 +419,13 @@ static int __init nforce2_init(void) return -ENODEV; } - return cpufreq_register_driver(&nforce2_driver); + ret = cpufreq_register_driver(&nforce2_driver); + if (ret) { + pci_dev_put(nforce2_dev); + nforce2_dev = NULL; + } + + return ret; } /** -- 2.43.0