Re: [RESEND][PATCH] scsi: dc395x: fix a missing check on list iterator

From: Martin K. Petersen
Date: Tue Apr 26 2022 - 08:53:16 EST


> The bug is here:
> p->target_id, p->target_lun);
> The list iterator 'p' will point to a bogus position containing HEAD
> if the list is empty or no element is found. This case must be checked
> before any use of the iterator, otherwise it will lead to a invalid
> memory access.
> To fix this bug, add an check. Use a new variable 'iter' as the list
> iterator, while use the origin variable 'p' as a dedicated pointer to
> point to the found element.

Applied to 5.19/scsi-staging, thanks!

Martin K. Petersen Oracle Linux Engineering