From 989d49990e0dc0b826758ab441e6af7c51a3aaf6 Mon Sep 17 00:00:00 2001 From: Niranjan Dighe Date: Thu, 18 Oct 2018 16:28:32 +0530 Subject: [PATCH] nvadsp: adspff: Fix kernel crash if file not found Check file->fp for NULL before returning the file handle to ADSP in adspff_fopen, which otherwise results in a kernel crash on successive file operations using the same file handle if the requested file does not exist. Jira: EMA-1152 Change-Id: I307cc82dd3a2135039b819d1f746ee8164568110 Signed-off-by: Niranjan Dighe Reviewed-on: https://git-master.nvidia.com/r/1929809 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Uday Gupta Reviewed-by: Hariharan Sivaraman Reviewed-by: Nitin Pai Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/platform/tegra/nvadsp/adspff.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/platform/tegra/nvadsp/adspff.c b/drivers/platform/tegra/nvadsp/adspff.c index 210dd65e..f76d5354 100644 --- a/drivers/platform/tegra/nvadsp/adspff.c +++ b/drivers/platform/tegra/nvadsp/adspff.c @@ -11,6 +11,8 @@ * more details. */ +#define pr_fmt(fmt) "adspff: " fmt + #include #include #include @@ -175,6 +177,13 @@ void adspff_fopen(struct work_struct *work) file->wr_offset = 0; file->rd_offset = 0; + if (!(file->fp)) { + kfree(file); + file = NULL; + pr_err("File not found - %s\n", + (const char *) message->msg.payload.fopen_msg.fname); + } + msg_recv->msgq_msg.size = MSGQ_MSG_SIZE(struct fopen_recv_msg_t); msg_recv->msg.payload.fopen_recv_msg.file = (int64_t)file;