]> git.sur5r.net Git - u-boot/commitdiff
efi_loader: correctly determine length of empty device path
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 16 Apr 2018 05:59:07 +0000 (07:59 +0200)
committerAlexander Graf <agraf@suse.de>
Mon, 23 Apr 2018 19:34:28 +0000 (21:34 +0200)
efi_dp_size() is meant to return the device path length without the end
node.

The length of a device path containing only an end node was incorrectly
reported as 4.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
lib/efi_loader/efi_device_path.c

index 9b4d9ae0abb7288451a4392a18f3aafab3dcac18..a2e48851d79e6181b7059012a1fab49deceb0132 100644 (file)
@@ -234,6 +234,8 @@ unsigned efi_dp_size(const struct efi_device_path *dp)
 {
        unsigned sz = 0;
 
+       if (!dp || dp->type == DEVICE_PATH_TYPE_END)
+               return 0;
        while (dp) {
                sz += dp->length;
                dp = efi_dp_next(dp);