提交 5fb43798 编写于 作者: S Sudip Mukherjee 提交者: Greg Kroah-Hartman

misc: mic: use common error path

Instead of calling release_firmware() on every error and then jumping
lets have a common release_firmware() in the error path.
This patch also fixes a memory leak where we missed release_firmware()
if mic_x100_load_command_line() fails.
Signed-off-by: NSudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: NSudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 fbaa72d5
...@@ -463,8 +463,7 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf) ...@@ -463,8 +463,7 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf)
rc = -EINVAL; rc = -EINVAL;
dev_err(&mdev->pdev->dev, "%s %d rc %d bootaddr 0x%x\n", dev_err(&mdev->pdev->dev, "%s %d rc %d bootaddr 0x%x\n",
__func__, __LINE__, rc, mdev->bootaddr); __func__, __LINE__, rc, mdev->bootaddr);
release_firmware(fw); goto error;
goto done;
} }
memcpy_toio(mdev->aper.va + mdev->bootaddr, fw->data, fw->size); memcpy_toio(mdev->aper.va + mdev->bootaddr, fw->data, fw->size);
mdev->ops->write_spad(mdev, MIC_X100_FW_SIZE, fw->size); mdev->ops->write_spad(mdev, MIC_X100_FW_SIZE, fw->size);
...@@ -472,22 +471,24 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf) ...@@ -472,22 +471,24 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf)
rc = -EINVAL; rc = -EINVAL;
dev_err(&mdev->pdev->dev, "%s %d rc %d\n", dev_err(&mdev->pdev->dev, "%s %d rc %d\n",
__func__, __LINE__, rc); __func__, __LINE__, rc);
release_firmware(fw); goto error;
goto done;
} }
/* load command line */ /* load command line */
rc = mic_x100_load_command_line(mdev, fw); rc = mic_x100_load_command_line(mdev, fw);
if (rc) { if (rc) {
dev_err(&mdev->pdev->dev, "%s %d rc %d\n", dev_err(&mdev->pdev->dev, "%s %d rc %d\n",
__func__, __LINE__, rc); __func__, __LINE__, rc);
goto done; goto error;
} }
release_firmware(fw); release_firmware(fw);
/* load ramdisk */ /* load ramdisk */
if (mdev->cosm_dev->ramdisk) if (mdev->cosm_dev->ramdisk)
rc = mic_x100_load_ramdisk(mdev); rc = mic_x100_load_ramdisk(mdev);
done: return rc;
error:
release_firmware(fw);
return rc; return rc;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册