gpu: nvgpu: Fix memory leak in arb install

nvgpu_clk_arb_install_fd() leaks dev if it cannot create an fd,
and it leaks both dev and fd if it fails to create a file.

Change-Id: I65c03401dba44d88be543d3aec2fa3fcd2fb0dcc
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/1279225
GVS: Gerrit_Virtual_Submit
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
This commit is contained in:
Terje Bergstrom
2016-12-20 15:15:44 -08:00
committed by mobile promotions
parent bffa372aa0
commit 685b4d351e

View File

@@ -332,15 +332,17 @@ static int nvgpu_clk_arb_install_fd(struct gk20a *g,
return -ENOMEM;
fd = get_unused_fd_flags(O_RDWR);
if (fd < 0)
return fd;
if (fd < 0) {
err = fd;
goto fail;
}
name = kasprintf(GFP_KERNEL, "%s-clk-fd%d", dev_name(g->dev), fd);
file = anon_inode_getfile(name, fops, dev, O_RDWR);
kfree(name);
if (IS_ERR(file)) {
err = PTR_ERR(file);
goto fail;
goto fail_fd;
}
fd_install(fd, file);
@@ -357,9 +359,10 @@ static int nvgpu_clk_arb_install_fd(struct gk20a *g,
return fd;
fail_fd:
put_unused_fd(fd);
fail:
kfree(dev);
put_unused_fd(fd);
return err;
}