From 59465bdf8794461455f27f385a706e85cf68d353 Mon Sep 17 00:00:00 2001 From: Weiguang Kong Date: Fri, 28 Jul 2017 16:42:32 +0800 Subject: [PATCH] MLK-16099-1: ASoc: fsl: fix crash issue when no dsp core lib When dsp driver can't find the dsp core lib in loading codec process, the kernel will be crashed. This issue is caused by unreasonable way of error handling. By changing the way of error handling to fix this issue. Signed-off-by: Weiguang Kong --- sound/soc/fsl/fsl_hifi4.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_hifi4.c b/sound/soc/fsl/fsl_hifi4.c index 95a4a57364fa..e1818809c32d 100644 --- a/sound/soc/fsl/fsl_hifi4.c +++ b/sound/soc/fsl/fsl_hifi4.c @@ -141,8 +141,8 @@ long load_dpu_with_library(struct fsl_hifi4 *hifi4_priv) /* Load DPU's main program to System memory */ fpInfile = file_open_name(hifi4_priv->objfile, O_RDONLY, 0); - if (!fpInfile) - return -1; + if (IS_ERR(fpInfile)) + return PTR_ERR(fpInfile); vfs_llseek(fpInfile, 0, SEEK_END); filesize = (int)fpInfile->f_pos; @@ -911,6 +911,7 @@ static long fsl_hifi4_load_codec(struct fsl_hifi4 *hifi4_priv, void __user *user) { struct device *dev = hifi4_priv->dev; + struct filename *fpInfile; struct binary_info binary_info; long ret = 0; @@ -920,10 +921,21 @@ static long fsl_hifi4_load_codec(struct fsl_hifi4 *hifi4_priv, return ret; } - hifi4_priv->objfile = getname(binary_info.file); + fpInfile = getname(binary_info.file); + if (IS_ERR(fpInfile)) { + dev_err(dev, "failed to getname(), err = %ld\n", + PTR_ERR(fpInfile)); + return PTR_ERR(fpInfile); + } + + hifi4_priv->objfile = fpInfile; hifi4_priv->objtype = binary_info.type; ret = load_dpu_with_library(hifi4_priv); + if (ret) { + dev_err(dev, "failed to load code binary, err = %ld\n", ret); + return ret; + } hifi4_priv->ret_status = 0; @@ -937,6 +949,7 @@ static long fsl_hifi4_load_codec_compat32(struct fsl_hifi4 *hifi4_priv, void __user *user) { struct device *dev = hifi4_priv->dev; + struct filename *fpInfile; struct binary_info binary_info; long ret = 0; @@ -946,10 +959,21 @@ static long fsl_hifi4_load_codec_compat32(struct fsl_hifi4 *hifi4_priv, return ret; } - hifi4_priv->objfile = getname(binary_info.file); + fpInfile = getname(binary_info.file); + if (IS_ERR(fpInfile)) { + dev_err(dev, "failed to getname(), err = %ld\n", + PTR_ERR(fpInfile)); + return PTR_ERR(fpInfile); + } + + hifi4_priv->objfile = fpInfile; hifi4_priv->objtype = binary_info.type; ret = load_dpu_with_library(hifi4_priv); + if (ret) { + dev_err(dev, "failed to load code binary, err = %ld\n", ret); + return ret; + } hifi4_priv->ret_status = 0; -- 2.17.1