thunderbolt: Fix memory leaks in {port|retimer}_sb_regs_write()
Subsystems (2)
PATCH 1/1 thunderbolt: Fix memory leaks in {port|retimer}_sb_regs_write()
From: Aapo Vienamo <[email protected]>
Add missing free_page() call for the memory allocated by validate_and_copy_from_user().
Fixes 6d241fa00159 ("thunderbolt: Add sideband register access to debugfs")
Signed-off-by Aapo Vienamo <[email protected]>
Reviewed-by Przemek Kitszel <[email protected]>
Signed-off-by Mika Westerberg <[email protected]>
--- drivers/thunderbolt/debugfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/thunderbolt/debugfs.c +6 -4
@@ -323,16 +323,17 @@ static ssize_t port_sb_regs_write(struct file *file, const char __user *user_bufif (mutex_lock_interruptible (&tb->lock)) { ret = -ERESTARTSYS ; - goto out_rpm_put; + goto out; } ret =sb_regs_write (port, port_sb_regs,ARRAY_SIZE (port_sb_regs),USB4_SB_TARGET_ROUTER ,0 , buf, count, ppos);mutex_unlock (&tb->lock); -out_rpm_put: +out:pm_runtime_mark_last_busy (&sw->dev);pm_runtime_put_autosuspend (&sw->dev); +free_page ((unsigned long )buf);return ret <0 ? ret : count; }
@@ -355,16 +356,17 @@ static ssize_t retimer_sb_regs_write(struct file *file,if (mutex_lock_interruptible (&tb->lock)) { ret = -ERESTARTSYS ; - goto out_rpm_put; + goto out; } ret =sb_regs_write (rt->port, retimer_sb_regs,ARRAY_SIZE (retimer_sb_regs),USB4_SB_TARGET_RETIMER , rt->index, buf, count, ppos);mutex_unlock (&tb->lock); -out_rpm_put: +out:pm_runtime_mark_last_busy (&rt->dev);pm_runtime_put_autosuspend (&rt->dev); +free_page ((unsigned long )buf);return ret <0 ? ret : count; }
Signature · 1 line
2.43.0
Mika Westerberg
AppliedQuoted 9 lines · Mika Westerberg
From: Aapo Vienamo <[email protected]>
Add missing
free_page()call for the memory allocated byvalidate_and_copy_from_user().Fixes 6d241fa00159 ("thunderbolt: Add sideband register access to debugfs")Signed-off-by Aapo Vienamo <[email protected]>Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Mika Westerberg <[email protected]>
Applied to thunderbolt.git/fixes.