mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: hold ch ref when getting ch from fd
Fix a race condition in gk20a_get_channel_from_file() that returns a channel pointer from an fd: take a reference to the channel before putting the file ref back. Now the caller is responsible of releasing the channel reference eventually. Also document why dbg_session_channel_data has to hold a ref to the channel file instead of just the channel: that might deadlock if the fds were closed in "wrong" order. Change-Id: I8e91b809f5f7b1cb0c1487bd955ad6d643727a53 Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1549290 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
de0ce3e017
commit
17451138cf
@@ -260,8 +260,15 @@ static int gk20a_init_error_notifier(struct channel_gk20a *ch,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This returns the channel with a reference. The caller must
|
||||
* gk20a_channel_put() the ref back after use.
|
||||
*
|
||||
* NULL is returned if the channel was not found.
|
||||
*/
|
||||
struct channel_gk20a *gk20a_get_channel_from_file(int fd)
|
||||
{
|
||||
struct channel_gk20a *ch;
|
||||
struct channel_priv *priv;
|
||||
struct file *f = fget(fd);
|
||||
|
||||
@@ -274,8 +281,9 @@ struct channel_gk20a *gk20a_get_channel_from_file(int fd)
|
||||
}
|
||||
|
||||
priv = (struct channel_priv *)f->private_data;
|
||||
ch = gk20a_channel_get(priv->c);
|
||||
fput(f);
|
||||
return priv->c;
|
||||
return ch;
|
||||
}
|
||||
|
||||
int gk20a_channel_release(struct inode *inode, struct file *filp)
|
||||
|
||||
Reference in New Issue
Block a user