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

Commit 4282d54f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: synaptics: add NULL pointer check"

parents 2a821032 66af29b2
Loading
Loading
Loading
Loading
+28 −9
Original line number Diff line number Diff line
@@ -1612,16 +1612,23 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,

	fhandler->fn_number = fd->fn_number;
	fhandler->num_of_data_sources = fd->intr_src_count;
	size_of_2d_data = sizeof(struct synaptics_rmi4_f12_finger_data);

	fhandler->extra = kmalloc(sizeof(*extra_data), GFP_KERNEL);
	if (!fhandler->extra) {
		dev_err(rmi4_data->pdev->dev.parent,
			"%s: Failed to alloc mem for function handler\n",
			__func__);
		return -ENOMEM;
	}
	extra_data = (struct synaptics_rmi4_f12_extra_data *)fhandler->extra;
	size_of_2d_data = sizeof(struct synaptics_rmi4_f12_finger_data);

	retval = synaptics_rmi4_reg_read(rmi4_data,
			fhandler->full_addr.query_base + 5,
			query_5.data,
			sizeof(query_5.data));
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	ctrl_8_offset = query_5.ctrl0_is_present +
			query_5.ctrl1_is_present +
@@ -1661,7 +1668,7 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
			ctrl_23.data,
			sizeof(ctrl_23.data));
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	/* Maximum number of fingers supported */
	fhandler->num_of_data_points = min(ctrl_23.max_reported_objects,
@@ -1675,14 +1682,14 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
			&size_of_query8,
			sizeof(size_of_query8));
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	retval = synaptics_rmi4_reg_read(rmi4_data,
			fhandler->full_addr.query_base + 8,
			query_8.data,
			size_of_query8);
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	/* Determine the presence of the Data0 register */
	extra_data->data1_offset = query_8.data0_is_present;
@@ -1719,14 +1726,14 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
	retval = synaptics_rmi4_f12_set_enables(rmi4_data,
			fhandler->full_addr.ctrl_base + ctrl_28_offset);
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	retval = synaptics_rmi4_reg_read(rmi4_data,
			fhandler->full_addr.ctrl_base + ctrl_8_offset,
			ctrl_8.data,
			sizeof(ctrl_8.data));
	if (retval < 0)
		return retval;
		goto free_function_handler_mem;

	/* Maximum x and y */
	rmi4_data->sensor_max_x =
@@ -1743,7 +1750,8 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
				bdata->panel_maxy > SYNA_F12_MAX) {
			dev_err(rmi4_data->pdev->dev.parent,
				"%s: Invalid panel resolution\n", __func__);
			return -EINVAL;
			retval = -EINVAL;
			goto free_function_handler_mem;
		}

		rmi4_data->sensor_max_x = bdata->panel_maxx;
@@ -1760,7 +1768,7 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
				ctrl_8.data,
				sizeof(ctrl_8.data));
		if (retval < 0)
			return retval;
			goto free_function_handler_mem;
	}

	dev_dbg(rmi4_data->pdev->dev.parent,
@@ -1779,8 +1787,19 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
	/* Allocate memory for finger data storage space */
	fhandler->data_size = num_of_fingers * size_of_2d_data;
	fhandler->data = kmalloc(fhandler->data_size, GFP_KERNEL);
	if (!fhandler->data) {
		dev_err(rmi4_data->pdev->dev.parent,
			"%s: Failed to alloc mem for function handler data\n",
			__func__);
		retval = -ENOMEM;
		goto free_function_handler_mem;
	}

	return retval;

free_function_handler_mem:
	kfree(fhandler->extra);
	return retval;
}

static int synaptics_rmi4_f1a_alloc_mem(struct synaptics_rmi4_data *rmi4_data,
+15 −0
Original line number Diff line number Diff line
@@ -663,6 +663,14 @@ static enum flash_area fwu_go_nogo(struct image_header_data *header)

		strptr += 2;
		firmware_id = kzalloc(MAX_FIRMWARE_ID_LEN, GFP_KERNEL);
		if (!firmware_id) {
			dev_err(rmi4_data->pdev->dev.parent,
				"%s: Failed to alloc mem for firmware id\n",
				__func__);
			flash_area = NONE;
			goto exit;
		}

		while (strptr[index] >= '0' && strptr[index] <= '9') {
			firmware_id[index] = strptr[index];
			index++;
@@ -1253,6 +1261,13 @@ static int fwu_do_read_config(void)

	kfree(fwu->read_config_buf);
	fwu->read_config_buf = kzalloc(fwu->config_size, GFP_KERNEL);
	if (!fwu->read_config_buf) {
		dev_err(rmi4_data->pdev->dev.parent,
			"%s: Failed to alloc memory for config buffer\n",
			__func__);
		retval = -ENOMEM;
		goto exit;
	}

	block_offset[1] |= (fwu->config_area << 5);

+7 −1
Original line number Diff line number Diff line
@@ -1402,7 +1402,13 @@ static int fwu_do_read_config(void)

	kfree(fwu->read_config_buf);
	fwu->read_config_buf = kzalloc(fwu->config_size, GFP_KERNEL);

	if (!fwu->read_config_buf) {
		dev_err(&fwu->rmi4_data->i2c_client->dev,
			"%s: Failed to alloc memory for config buffer\n",
			__func__);
		retval = -ENOMEM;
		goto exit;
	}
	block_offset[1] |= (fwu->config_area << 5);

	retval = fwu->fn_ptr->write(fwu->rmi4_data,