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

Commit ee86fb3c authored by Domi Papoi's avatar Domi Papoi Committed by Gerrit - the friendly Code Review server
Browse files

msm: BA: Avoid null pointer dereferencing



Add null pointer checking to avoid null pointer dereferencing
for ba input.

Change-Id: Ic54bbf8748a78c7f33540cab2ec32b753969fa06
Signed-off-by: default avatarDomi Papoi <dpapoi@codeaurora.org>
parent 25a2528e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -524,14 +524,18 @@ int msm_ba_save_restore_input(void *instance, enum msm_ba_save_restore_ip sr)
		msm_ba_reset_ip_in_use_from_sd(inst->sd);
		ba_input = msm_ba_find_input_from_sd(inst->sd,
					inst->saved_input);
		if (ba_input)
			ba_input->in_use = 1;
		else
			dprintk(BA_WARN, "Could not find input %d from sd: %s",
				inst->saved_input, inst->sd->name);
		inst->restore = 0;
		inst->saved_input = BA_IP_MAX;
		dprintk(BA_DBG, "Stream on from save restore");
		rc = msm_ba_streamon(inst, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
	} else if (BA_SR_SAVE_IP == sr) {
		ba_input = msm_ba_find_input(inst->sd_input.index);
		if (ba_input->ba_out_in_use) {
		if (ba_input && ba_input->ba_out_in_use) {
			inst->restore = 1;
			inst->saved_input =
				msm_ba_find_ip_in_use_from_sd(inst->sd);
@@ -543,6 +547,9 @@ int msm_ba_save_restore_input(void *instance, enum msm_ba_save_restore_ip sr)
				inst->saved_input);
			rc = -EBUSY;
		}
		if (!ba_input)
			dprintk(BA_WARN, "Couldn't find input idx %d to save",
				inst->sd_input.index);
	} else {
		dprintk(BA_DBG, "Nothing to do in save and restore");
	}