]> git.ipfire.org Git - thirdparty/linux.git/commit
hwmon: (drivetemp) Fix driver producing garbage data when SCSI errors occur
authorDaniil Stas <daniil.stas@posteo.net>
Sun, 5 Jan 2025 21:36:18 +0000 (21:36 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 8 Jan 2025 00:36:01 +0000 (16:36 -0800)
commit82163d63ae7a4c36142cd252388737205bb7e4b9
tree14d6933fd92e25d3460387c0774ee326c55d1cb4
parent9d89551994a430b50c4fffcb1e617a057fa76e20
hwmon: (drivetemp) Fix driver producing garbage data when SCSI errors occur

scsi_execute_cmd() function can return both negative (linux codes) and
positive (scsi_cmnd result field) error codes.

Currently the driver just passes error codes of scsi_execute_cmd() to
hwmon core, which is incorrect because hwmon only checks for negative
error codes. This leads to hwmon reporting uninitialized data to
userspace in case of SCSI errors (for example if the disk drive was
disconnected).

This patch checks scsi_execute_cmd() output and returns -EIO if it's
error code is positive.

Fixes: 5b46903d8bf37 ("hwmon: Driver for disk and solid state drives with temperature sensors")
Signed-off-by: Daniil Stas <daniil.stas@posteo.net>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Cc: linux-ide@vger.kernel.org
Cc: linux-hwmon@vger.kernel.org
Link: https://lore.kernel.org/r/20250105213618.531691-1-daniil.stas@posteo.net
[groeck: Avoid inline variable declaration for portability]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/drivetemp.c