scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry()
authorHarshvardhan Jha <harshvardhan.jha@oracle.com>
Thu, 8 Jul 2021 07:46:42 +0000 (13:16 +0530)
committerSasha Levin <sashal@kernel.org>
Thu, 26 Aug 2021 12:37:26 +0000 (08:37 -0400)
commit881dff363d838118047f135fed77f8ffa396e2ad
treeb7b05e076a26d8b8a5bc47824b842922e282db62
parentb116976b6c66e985b3435d8de3c14b040eb5a587
scsi: megaraid_mm: Fix end of loop tests for list_for_each_entry()

[ Upstream commit 77541f78eadfe9fdb018a7b8b69f0f2af2cf4b82 ]

The list_for_each_entry() iterator, "adapter" in this code, can never be
NULL.  If we exit the loop without finding the correct adapter then
"adapter" points invalid memory that is an offset from the list head.  This
will eventually lead to memory corruption and presumably a kernel crash.

Link: https://lore.kernel.org/r/20210708074642.23599-1-harshvardhan.jha@oracle.com
Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Harshvardhan Jha <harshvardhan.jha@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/megaraid/megaraid_mm.c