Skip to content

Commit 95fc36a

Browse files
jhovoldgregkh
authored andcommitted
intel_th: fix device leak on output open()
Make sure to drop the reference taken when looking up the th device during output device open() on errors and on close(). Note that a recent commit fixed the leak in a couple of open() error paths but not all of them, and the reference is still leaking on successful open(). Fixes: 39f4034 ("intel_th: Add driver infrastructure for Intel(R) Trace Hub devices") Fixes: 6d5925b ("intel_th: Fix error handling in intel_th_output_open") Cc: stable@vger.kernel.org # 4.4: 6d5925b Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ma Ke <make24@iscas.ac.cn> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20251208153524.68637-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 10d28cf commit 95fc36a

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • drivers/hwtracing/intel_th

drivers/hwtracing/intel_th/core.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,12 @@ static int intel_th_output_open(struct inode *inode, struct file *file)
810810
int err;
811811

812812
dev = bus_find_device_by_devt(&intel_th_bus, inode->i_rdev);
813-
if (!dev || !dev->driver) {
813+
if (!dev)
814+
return -ENODEV;
815+
816+
if (!dev->driver) {
814817
err = -ENODEV;
815-
goto out_no_device;
818+
goto out_put_device;
816819
}
817820

818821
thdrv = to_intel_th_driver(dev->driver);
@@ -836,12 +839,22 @@ static int intel_th_output_open(struct inode *inode, struct file *file)
836839

837840
out_put_device:
838841
put_device(dev);
839-
out_no_device:
842+
840843
return err;
841844
}
842845

846+
static int intel_th_output_release(struct inode *inode, struct file *file)
847+
{
848+
struct intel_th_device *thdev = file->private_data;
849+
850+
put_device(&thdev->dev);
851+
852+
return 0;
853+
}
854+
843855
static const struct file_operations intel_th_output_fops = {
844856
.open = intel_th_output_open,
857+
.release = intel_th_output_release,
845858
.llseek = noop_llseek,
846859
};
847860

0 commit comments

Comments
 (0)