From 1b5035132b8f28cb05a21eca4d2f7a4771e59914 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Tue, 25 Jul 2017 15:20:49 -0700 Subject: gpu: nvgpu: check for null priv in channel_release gk20a_channel_release can still get called even if the open_channel call failed (e.g., if we ran out of hw chids), in which case priv is null. Check for this case and return if null. Bug 1964531 Change-Id: I48bc88e4dbd88a1c30fc399de629d8f8b344cfd9 Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/1526544 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: Vijayakumar Subbu --- drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux') diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index 2242e19e..ab02dc42 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c @@ -281,11 +281,20 @@ struct channel_gk20a *gk20a_get_channel_from_file(int fd) int gk20a_channel_release(struct inode *inode, struct file *filp) { struct channel_priv *priv = filp->private_data; - struct channel_gk20a *ch = priv->c; - struct gk20a *g = priv->g; + struct channel_gk20a *ch; + struct gk20a *g; int err; + /* We could still end up here even if the channel_open failed, e.g. + * if we ran out of hw channel IDs. + */ + if (!priv) + return 0; + + ch = priv->c; + g = priv->g; + err = gk20a_busy(g); if (err) { nvgpu_err(g, "failed to release a channel!"); -- cgit v1.2.2