Skip to content

Commit 447e118

Browse files
GeorgeCGVcfriedt
authored andcommitted
drivers: eth: oa_tc6: fix status check garbage value
If reading the status register fails, the register `sts` will contain meaningless data. In such cases, the function should return an error and not attempt to clear any pending interrupts with invalid data. Signed-off-by: Georgij Černyšiov <[email protected]>
1 parent 37f9aed commit 447e118

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/ethernet/oa_tc6.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,19 @@ int oa_tc6_check_status(struct oa_tc6 *tc6)
303303
* The RESETC is handled separately as it requires per
304304
* device configuration.
305305
*/
306-
oa_tc6_reg_read(tc6, OA_STATUS0, &sts);
306+
if (oa_tc6_reg_read(tc6, OA_STATUS0, &sts) < 0) {
307+
return -EIO;
308+
}
309+
307310
if (sts != 0) {
308311
oa_tc6_reg_write(tc6, OA_STATUS0, sts);
309312
LOG_WRN("EXST: OA_STATUS0: 0x%x", sts);
310313
}
311314

312-
oa_tc6_reg_read(tc6, OA_STATUS1, &sts);
315+
if (oa_tc6_reg_read(tc6, OA_STATUS1, &sts) < 0) {
316+
return -EIO;
317+
}
318+
313319
if (sts != 0) {
314320
oa_tc6_reg_write(tc6, OA_STATUS1, sts);
315321
LOG_WRN("EXST: OA_STATUS1: 0x%x", sts);

0 commit comments

Comments
 (0)