[tip:efi/urgent] efi: Make for_each_efi_memory_desc_in_map() cope with running on Xen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  d4c4fed08f31f3746000c46cb1b20bed2959547a
Gitweb:     http://git.kernel.org/tip/d4c4fed08f31f3746000c46cb1b20bed2959547a
Author:     Jan Beulich <JBeulich@xxxxxxxx>
AuthorDate: Mon, 15 Aug 2016 09:05:45 -0600
Committer:  Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx>
CommitDate: Mon, 5 Sep 2016 11:16:56 +0100

efi: Make for_each_efi_memory_desc_in_map() cope with running on Xen

While commit 55f1ea15216 ("efi: Fix for_each_efi_memory_desc_in_map()
for empty memmaps") made an attempt to deal with empty memory maps, it
didn't address the case where the map field never gets set, as is
apparently the case when running under Xen.

Reported-by: <lists@xxxxxxxxxxxx>
Tested-by: <lists@xxxxxxxxxxxx>
Cc: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
Cc: Jiri Slaby <jslaby@xxxxxxx>
Cc: Mark Rutland <mark.rutland@xxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx> # v4.7+
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
[ Guard the loop with a NULL check instead of pointer underflow ]
Signed-off-by: Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx>
---
 include/linux/efi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/efi.h b/include/linux/efi.h
index 7f5a582..23cd3ce 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -946,7 +946,7 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm,
 /* Iterate through an efi_memory_map */
 #define for_each_efi_memory_desc_in_map(m, md)				   \
 	for ((md) = (m)->map;						   \
-	     ((void *)(md) + (m)->desc_size) <= (m)->map_end;		   \
+	     (md) && ((void *)(md) + (m)->desc_size) <= (m)->map_end;	   \
 	     (md) = (void *)(md) + (m)->desc_size)
 
 /**
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux