[PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs

David Heidelberg david at ixit.cz
Fri Nov 27 12:35:34 PST 2026


On 27/11/2026 21:09, Lee Jones wrote:
> i2c_smbus_read_i2c_block_data() returns the positive byte count on
> success or a negative error code on failure.  stmfts_sysfs_read_status()
> checks if (err) and returns err directly, so a normal 4-byte read
> returns 4 without formatting buf (exposing unpopulated sysfs buffer
> bytes), while a 0-byte read formats uninitialised stack memory.
> 
> Return negative errors immediately and require sizeof(status) bytes to
> be read, matching stmfts_read_system_info().
> 
> Fixes: 78bcac7b2ae1 ("Input: add support for the STMicroelectronics FingerTip touchscreen")
> Closes: https://sashiko.dev/#/bug/linux-bd87edf0-6f79-4318-8780-d69205787e7d
> Cc: stable at vger.kernel.org
> Signed-off-by: Lee Jones <lee at kernel.org>
> ---
>   drivers/input/touchscreen/stmfts.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/stmfts.c b/drivers/input/touchscreen/stmfts.c
> index 2054c2254947..aada03f96940 100644
> --- a/drivers/input/touchscreen/stmfts.c
> +++ b/drivers/input/touchscreen/stmfts.c
> @@ -699,9 +699,12 @@ static ssize_t stmfts_sysfs_read_status(struct device *dev,
>   
>   	err = i2c_smbus_read_i2c_block_data(sdata->client, STMFTS_READ_STATUS,
>   					    sizeof(status), status);
> -	if (err)
> +	if (err < 0)
>   		return err;
>   
> +	if (err != sizeof(status))
> +		return -EIO;
> +
>   	return sysfs_emit(buf, "%#02x\n", status[0]);
>   }
>   

Reviewed-by: David Heidelberg <david at ixit.cz>



More information about the linux-arm-kernel mailing list