]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ata: sata_sx4: Add error handling in pdc20621_i2c_read()
authorWentao Liang <vulab@iscas.ac.cn>
Tue, 8 Apr 2025 07:30:01 +0000 (15:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:08 +0000 (10:45 +0200)
commit44984339d38ea000f0d07ca9b9bf1cf47ca6cae9
treea7011267a187f236288ce91726c0550f3097a0ce
parentc17ef974bfcf1a50818168b47c4606b425a957c4
ata: sata_sx4: Add error handling in pdc20621_i2c_read()

[ Upstream commit 8d46a27085039158eb5e253ab8a35a0e33b5e864 ]

The function pdc20621_prog_dimm0() calls the function pdc20621_i2c_read()
but does not handle the error if the read fails. This could lead to
process with invalid data. A proper implementation can be found in
/source/drivers/ata/sata_sx4.c, pdc20621_prog_dimm_global(). As mentioned
in its commit: bb44e154e25125bef31fa956785e90fccd24610b, the variable spd0
might be used uninitialized when pdc20621_i2c_read() fails.

Add error handling to pdc20621_i2c_read(). If a read operation fails,
an error message is logged via dev_err(), and return a negative error
code.

Add error handling to pdc20621_prog_dimm0() in pdc20621_dimm_init(), and
return a negative error code if pdc20621_prog_dimm0() fails.

Fixes: 4447d3515616 ("libata: convert the remaining SATA drivers to new init model")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ata/sata_sx4.c