소스 검색

efi_loader: correctly determine length of empty device path

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>
Heinrich Schuchardt 7 년 전
부모
커밋
adb575124d
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      lib/efi_loader/efi_device_path.c

+ 2 - 0
lib/efi_loader/efi_device_path.c

@@ -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);