Re: [PATCH v1 4/5] Input: edt-ft5x06 - do not try to allocate too much memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 03, 2020 at 08:09:16PM +0200, Andy Shevchenko wrote:
> When mode switch happens we try to allocate too much memory in case
> when num_x and num_y are being assigned to their maximum.
> 
> Since the resolution should come from property in such case, reassign
> values back to num_x and num_y to prevent too much memory allocation.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index a05c6b597d43..1023d4134b8d 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -1178,6 +1178,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  
>  	touchscreen_parse_properties(input, true, &tsdata->prop);
>  
> +	if (tsdata->num_x == U16_MAX && tsdata->prop.max_x &&
> +	    tsdata->num_y == U16_MAX && tsdata->prop.max_y) {
> +		/* Reassign num_x and num_y from properties */
> +		tsdata->num_x = tsdata->prop.max_x;
> +		tsdata->num_y = tsdata->prop.max_y;

No. num_x and num_y reprsenet number of electrodes on a given axis and
we should not be assigning maximum coordinates to them.

Moreover, the factory mode can only be activated on M06, where we do
read these values from registers, so we will not be allocating too much
memory. If anything, we should add error handling for
edt_ft5x06_register_read() when trying to fetch num_x and num_y.

Thanks.

-- 
Dmitry



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux