]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
intel_th: fix MSC output device reference leak
authorGuangshuo Li <lgs201920130244@gmail.com>
Wed, 15 Jul 2026 07:08:51 +0000 (15:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Jul 2026 12:52:08 +0000 (14:52 +0200)
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 95fc36a234da ("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: 95fc36a234da ("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>
drivers/hwtracing/intel_th/core.c
drivers/hwtracing/intel_th/msu.c

index 3924e63e2eeeb13bea3f8f3601b21fccd2c4d26d..56acf31546da56026f2955c6c47e99452d2c9530 100644 (file)
@@ -843,18 +843,8 @@ err_put_dev:
        return err;
 }
 
-static int intel_th_output_release(struct inode *inode, struct file *file)
-{
-       struct intel_th_device *thdev = file->private_data;
-
-       put_device(&thdev->dev);
-
-       return 0;
-}
-
 static const struct file_operations intel_th_output_fops = {
        .open   = intel_th_output_open,
-       .release = intel_th_output_release,
        .llseek = noop_llseek,
 };
 
index a82cf74f39ad5c95dbf8e1fa6fe4f758866a5ac1..84d99d7b1d20488f3d6c9046dfa56a7e81fab56c 100644 (file)
@@ -1490,8 +1490,10 @@ static int intel_th_msc_release(struct inode *inode, struct file *file)
 {
        struct msc_iter *iter = file->private_data;
        struct msc *msc = iter->msc;
+       struct intel_th_device *thdev = msc->thdev;
 
        msc_iter_remove(iter, msc);
+       put_device(&thdev->dev);
 
        return 0;
 }