Skip to content

Commit ddcf206

Browse files
lgs2513gregkh
authored andcommitted
intel_th: fix MSC output device reference leak
commit 761b785 upstream. intel_th_output_open() looks up the output device with bus_find_device_by_devt(), which returns the device with a reference that must be dropped after use. commit 95fc36a ("intel_th: fix device leak on output open()") attempted to drop the reference from intel_th_output_release(). However, a successful open replaces file->f_op with the output driver file operations before returning, so close runs the output driver release callback instead. For MSC outputs, close runs intel_th_msc_release(), which only removes the per-file iterator and does not drop the device reference taken by intel_th_output_open(). Consequently, every successful MSC output open leaks one device reference. Drop the device reference from intel_th_msc_release(), which is the release path actually used for MSC output files. Remove the now-unused intel_th_output_release() callback from intel_th_output_fops. Fixes: 95fc36a ("intel_th: fix device leak on output open()") Cc: stable <stable@kernel.org> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Reviewed-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260715070851.2077965-1-lgs201920130244@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 441559d commit ddcf206

2 files changed

Lines changed: 2 additions & 10 deletions

File tree

drivers/hwtracing/intel_th/core.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,8 @@ static int intel_th_output_open(struct inode *inode, struct file *file)
843843
return err;
844844
}
845845

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-
855846
static const struct file_operations intel_th_output_fops = {
856847
.open = intel_th_output_open,
857-
.release = intel_th_output_release,
858848
.llseek = noop_llseek,
859849
};
860850

drivers/hwtracing/intel_th/msu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,10 @@ static int intel_th_msc_release(struct inode *inode, struct file *file)
14741474
{
14751475
struct msc_iter *iter = file->private_data;
14761476
struct msc *msc = iter->msc;
1477+
struct intel_th_device *thdev = msc->thdev;
14771478

14781479
msc_iter_remove(iter, msc);
1480+
put_device(&thdev->dev);
14791481

14801482
return 0;
14811483
}

0 commit comments

Comments
 (0)