mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
Fix memory leak in posix_clock_open()
commit5b4cdd9c56
upstream. If the clk ops.open() function returns an error, we don't release the pccontext we allocated for this clock. Re-organize the code slightly to make it all more obvious. Reported-by: Rohit Keshri <rkeshri@redhat.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Fixes:60c6946675
("posix-clock: introduce posix_clock_context concept") Cc: Jakub Kicinski <kuba@kernel.org> Cc: David S. Miller <davem@davemloft.net> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Torvalds <torvalds@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3e52444ed1
commit
0200dd7ed2
@ -129,15 +129,17 @@ static int posix_clock_open(struct inode *inode, struct file *fp)
|
||||
goto out;
|
||||
}
|
||||
pccontext->clk = clk;
|
||||
fp->private_data = pccontext;
|
||||
if (clk->ops.open)
|
||||
if (clk->ops.open) {
|
||||
err = clk->ops.open(pccontext, fp->f_mode);
|
||||
else
|
||||
err = 0;
|
||||
|
||||
if (!err) {
|
||||
get_device(clk->dev);
|
||||
if (err) {
|
||||
kfree(pccontext);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
fp->private_data = pccontext;
|
||||
get_device(clk->dev);
|
||||
err = 0;
|
||||
out:
|
||||
up_read(&clk->rwsem);
|
||||
return err;
|
||||
|
Loading…
Reference in New Issue
Block a user