Skip to content

Commit cbc29f1

Browse files
Alexander Gordeevhcahca
authored andcommitted
s390/mem_detect: do not update output parameters on failure
Function __get_mem_detect_block() resets start and end output parameters in case of invalid mem_detect array index is provided. That violates the rule of sparing the output on fail path and leads e.g to a below anomaly: for_each_mem_detect_block(i, &start, &end) continue; One would expect start and end contain addresses of the last memory block (if available), but in fact the two will be reset to zeroes. That is not how an iterator is expected to work. Reviewed-by: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 0c6924c commit cbc29f1

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

arch/s390/include/asm/mem_detect.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ void add_mem_detect_block(u64 start, u64 end);
4040
static inline int __get_mem_detect_block(u32 n, unsigned long *start,
4141
unsigned long *end)
4242
{
43-
if (n >= mem_detect.count) {
44-
*start = 0;
45-
*end = 0;
43+
if (n >= mem_detect.count)
4644
return -1;
47-
}
4845

4946
if (n < MEM_INLINED_ENTRIES) {
5047
*start = (unsigned long)mem_detect.entries[n].start;

0 commit comments

Comments
 (0)