ses: fix additional element traversal bug
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Fri, 11 Dec 2015 17:16:38 +0000 (09:16 -0800)
committerZefan Li <lizefan@huawei.com>
Wed, 26 Oct 2016 15:15:37 +0000 (23:15 +0800)
commit0dd69de3c4f45c6e3af43e9146ee4679dbc45a33
treee12fe94a12bb98f9030ff607c9ac6d9f1cc5d9d7
parent1405c2b764791b8b6328d1e39059fb6780beef9e
ses: fix additional element traversal bug

commit 5e1033561da1152c57b97ee84371dba2b3d64c25 upstream.

KASAN found that our additional element processing scripts drop off
the end of the VPD page into unallocated space.  The reason is that
not every element has additional information but our traversal
routines think they do, leading to them expecting far more additional
information than is present.  Fix this by adding a gate to the
traversal routine so that it only processes elements that are expected
to have additional information (list is in SES-2 section 6.1.13.1:
Additional Element Status diagnostic page overview)

Reported-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Tested-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Zefan Li <lizefan@huawei.com>
drivers/scsi/ses.c
include/linux/enclosure.h