Commit ab3de2c7 authored by Aapo Vienamo's avatar Aapo Vienamo Committed by Mika Westerberg

thunderbolt: Fix memory leaks in {port|retimer}_sb_regs_write()

Add missing free_page() call for the memory allocated by
validate_and_copy_from_user().

Fixes: 6d241fa0 ("thunderbolt: Add sideband register access to debugfs")
Signed-off-by: default avatarAapo Vienamo <aapo.vienamo@linux.intel.com>
Reviewed-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 8400291e
...@@ -323,16 +323,17 @@ static ssize_t port_sb_regs_write(struct file *file, const char __user *user_buf ...@@ -323,16 +323,17 @@ static ssize_t port_sb_regs_write(struct file *file, const char __user *user_buf
if (mutex_lock_interruptible(&tb->lock)) { if (mutex_lock_interruptible(&tb->lock)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto out_rpm_put; goto out;
} }
ret = sb_regs_write(port, port_sb_regs, ARRAY_SIZE(port_sb_regs), ret = sb_regs_write(port, port_sb_regs, ARRAY_SIZE(port_sb_regs),
USB4_SB_TARGET_ROUTER, 0, buf, count, ppos); USB4_SB_TARGET_ROUTER, 0, buf, count, ppos);
mutex_unlock(&tb->lock); mutex_unlock(&tb->lock);
out_rpm_put: out:
pm_runtime_mark_last_busy(&sw->dev); pm_runtime_mark_last_busy(&sw->dev);
pm_runtime_put_autosuspend(&sw->dev); pm_runtime_put_autosuspend(&sw->dev);
free_page((unsigned long)buf);
return ret < 0 ? ret : count; return ret < 0 ? ret : count;
} }
...@@ -355,16 +356,17 @@ static ssize_t retimer_sb_regs_write(struct file *file, ...@@ -355,16 +356,17 @@ static ssize_t retimer_sb_regs_write(struct file *file,
if (mutex_lock_interruptible(&tb->lock)) { if (mutex_lock_interruptible(&tb->lock)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
goto out_rpm_put; goto out;
} }
ret = sb_regs_write(rt->port, retimer_sb_regs, ARRAY_SIZE(retimer_sb_regs), ret = sb_regs_write(rt->port, retimer_sb_regs, ARRAY_SIZE(retimer_sb_regs),
USB4_SB_TARGET_RETIMER, rt->index, buf, count, ppos); USB4_SB_TARGET_RETIMER, rt->index, buf, count, ppos);
mutex_unlock(&tb->lock); mutex_unlock(&tb->lock);
out_rpm_put: out:
pm_runtime_mark_last_busy(&rt->dev); pm_runtime_mark_last_busy(&rt->dev);
pm_runtime_put_autosuspend(&rt->dev); pm_runtime_put_autosuspend(&rt->dev);
free_page((unsigned long)buf);
return ret < 0 ? ret : count; return ret < 0 ? ret : count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment