lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250714132526.3216569-1-make24@iscas.ac.cn>
Date: Mon, 14 Jul 2025 21:25:26 +0800
From: Ma Ke <make24@...as.ac.cn>
To: mchehab@...nel.org,
	ribalda@...omium.org,
	rafael.j.wysocki@...el.com,
	dongcheng.yan@...el.com,
	gregkh@...uxfoundation.org,
	make24@...as.ac.cn,
	peterz@...radead.org,
	wentong.wu@...el.com,
	sakari.ailus@...ux.intel.com,
	andriy.shevchenko@...ux.intel.com
Cc: linux-media@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: [PATCH] media: pci: intel: Balance device refcount when destroying devices

Using ipu_bridge_get_ivsc_csi_dev() to locate the device could cause
an imbalance in the device's reference count.
ipu_bridge_get_ivsc_csi_dev() calls device_find_child_by_name() to
implement the localization, and device_find_child_by_name() calls an
implicit get_device() to increment the device's reference count before
returning the pointer. Throughout the entire implementation process,
no mechanism releases resources properly. This leads to a memory leak
because the reference count of the device is never decremented.

As the comment of device_find_child_by_name() says, 'NOTE: you will
need to drop the reference with put_device() after use'.

Found by code review.

Cc: stable@...r.kernel.org
Fixes: c66821f381ae ("media: pci: intel: Add IVSC support for IPU bridge driver")
Signed-off-by: Ma Ke <make24@...as.ac.cn>
---
 drivers/media/pci/intel/ipu-bridge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c
index 83e682e1a4b7..f8b4672accab 100644
--- a/drivers/media/pci/intel/ipu-bridge.c
+++ b/drivers/media/pci/intel/ipu-bridge.c
@@ -192,6 +192,7 @@ static int ipu_bridge_check_ivsc_dev(struct ipu_sensor *sensor,
 
 		sensor->csi_dev = csi_dev;
 		sensor->ivsc_adev = adev;
+		put_device(csi_dev);
 	}
 
 	return 0;
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ