Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 263e794b authored by Sultanxda's avatar Sultanxda Committed by TARKZiM
Browse files

msm: vidc: Fix broken debugfs creation error checks and error paths



The debugfs helper functions do not always return NULL when they fail;
instead, they can return an error number casted as a pointer, so that their
users have the option to determine the exact cause of failure.

Use the IS_ERR_OR_NULL() helper when checking for debugfs errors to fix the
error checks.

Change-Id: I7c2f5d45c6857e72ad2de200d642d018923040da
Signed-off-by: default avatarSultanxda <sultanxda@gmail.com>
parent 11e80f96
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ failed_create_dir:
struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core,
		struct dentry *parent)
{
	struct dentry *dir = NULL;
	struct dentry *dir;
	char debugfs_name[MAX_DEBUGFS_NAME];
	if (!core) {
		dprintk(VIDC_ERR, "Invalid params, core: %pK\n", core);
@@ -262,22 +262,24 @@ struct dentry *msm_vidc_debugfs_init_core(struct msm_vidc_core *core,

	snprintf(debugfs_name, MAX_DEBUGFS_NAME, "core%d", core->id);
	dir = debugfs_create_dir(debugfs_name, parent);
	if (!dir) {
	if (IS_ERR_OR_NULL(dir)) {
		dprintk(VIDC_ERR, "Failed to create debugfs for msm_vidc\n");
		goto failed_create_dir;
	}

	if (!debugfs_create_file("info", S_IRUGO, dir, core, &core_info_fops)) {
	if (IS_ERR_OR_NULL(debugfs_create_file("info", S_IRUGO, dir, core, &core_info_fops))) {
		dprintk(VIDC_ERR, "debugfs_create_file: fail\n");
		goto failed_create_dir;
		goto failed_create_file;
	}
	if (!debugfs_create_file("trigger_ssr", S_IWUSR,
			dir, core, &ssr_fops)) {
	if (IS_ERR_OR_NULL(debugfs_create_file("trigger_ssr", S_IWUSR,
			dir, core, &ssr_fops))) {
		dprintk(VIDC_ERR, "debugfs_create_file: fail\n");
		goto failed_create_dir;
		goto failed_create_file;
	}
failed_create_file:
	debugfs_remove_recursive(dir);
failed_create_dir:
	return dir;
	return NULL;
}

static int inst_info_open(struct inode *inode, struct file *file)
@@ -452,7 +454,7 @@ static const struct file_operations inst_info_fops = {
struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst,
		struct dentry *parent)
{
	struct dentry *dir = NULL, *info = NULL;
	struct dentry *dir, *info;
	char debugfs_name[MAX_DEBUGFS_NAME];
	struct core_inst_pair *idata = NULL;

@@ -473,14 +475,14 @@ struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst,
	idata->inst = inst;

	dir = debugfs_create_dir(debugfs_name, parent);
	if (!dir) {
	if (IS_ERR_OR_NULL(dir)) {
		dprintk(VIDC_ERR, "Failed to create debugfs for msm_vidc\n");
		goto failed_create_dir;
	}

	info = debugfs_create_file("info", S_IRUGO, dir,
			idata, &inst_info_fops);
	if (!info) {
	if (IS_ERR_OR_NULL(info)) {
		dprintk(VIDC_ERR, "debugfs_create_file: fail\n");
		goto failed_create_file;
	}
@@ -491,11 +493,10 @@ struct dentry *msm_vidc_debugfs_init_inst(struct msm_vidc_inst *inst,

failed_create_file:
	debugfs_remove_recursive(dir);
	dir = NULL;
failed_create_dir:
	kfree(idata);
exit:
	return dir;
	return NULL;
}

void msm_vidc_debugfs_deinit_inst(struct msm_vidc_inst *inst)