mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 18:41:23 +00:00
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>
This commit is contained in:
parent
0c6924c262
commit
cbc29f107e
@ -40,11 +40,8 @@ void add_mem_detect_block(u64 start, u64 end);
|
|||||||
static inline int __get_mem_detect_block(u32 n, unsigned long *start,
|
static inline int __get_mem_detect_block(u32 n, unsigned long *start,
|
||||||
unsigned long *end)
|
unsigned long *end)
|
||||||
{
|
{
|
||||||
if (n >= mem_detect.count) {
|
if (n >= mem_detect.count)
|
||||||
*start = 0;
|
|
||||||
*end = 0;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (n < MEM_INLINED_ENTRIES) {
|
if (n < MEM_INLINED_ENTRIES) {
|
||||||
*start = (unsigned long)mem_detect.entries[n].start;
|
*start = (unsigned long)mem_detect.entries[n].start;
|
||||||
|
Loading…
Reference in New Issue
Block a user