Package: efivar / 37-6

0001-Fix-the-error-path-in-set_disk_and_part_name.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From 22bc0866e941cbfe57de6522db51e9cf2c6b3ff1 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 2 Oct 2019 17:01:00 -0400
Subject: [PATCH] Fix the error path in set_disk_and_part_name()

Signed-off-by: Peter Jones <pjones@redhat.com>

[ dannf: Context adjustments due to upstream whitespace cleanup;
  Included to simplify the application of
  0003-Try-even-harder-to-find-disk-device-symlinks-in-sysf.patch ]

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1891718
Bug: https://github.com/rhboot/efivar/issues/157
Origin: upstream, https://github.com/rhboot/efivar/commit/22bc0866e941cbfe57de6522db51e9cf2c6b3ff1
Last-Updated: 2020-09-30

Index: efivar-37/src/linux.c
===================================================================
--- efivar-37.orig/src/linux.c
+++ efivar-37/src/linux.c
@@ -1,6 +1,6 @@
 /*
  * libefiboot - library for the manipulation of EFI boot variables
- * Copyright 2012-2015 Red Hat, Inc.
+ * Copyright 2012-2019 Red Hat, Inc.
  * Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
  *
  * This library is free software; you can redistribute it and/or
@@ -169,6 +169,8 @@ set_disk_name(struct device *dev, const
 int HIDDEN
 set_disk_and_part_name(struct device *dev)
 {
+	int rc = -1;
+
         /*
          * results are like such:
          * maj:min -> ../../devices/pci$PCI_STUFF/$BLOCKDEV_STUFF/block/$DISK/$PART
@@ -200,6 +202,7 @@ set_disk_and_part_name(struct device *de
                 set_disk_name(dev, "%s", penultimate);
                 set_part_name(dev, "%s", ultimate);
                 debug("disk:%s part:%s", penultimate, ultimate);
+		rc = 0;
         } else if (ultimate && approximate && !strcmp(approximate, "nvme")) {
                 /*
                  * 259:0 -> ../../devices/pci0000:00/0000:00:1d.0/0000:05:00.0/nvme/nvme0/nvme0n1
@@ -207,6 +210,7 @@ set_disk_and_part_name(struct device *de
                 set_disk_name(dev, "%s", ultimate);
                 set_part_name(dev, "%sp%d", ultimate, dev->part);
                 debug("disk:%s part:%sp%d", ultimate, ultimate, dev->part);
+		rc = 0;
         } else if (ultimate && penultimate && !strcmp(penultimate, "block")) {
                 /*
                  * 253:0 -> ../../devices/virtual/block/dm-0 (... I guess)
@@ -220,15 +224,19 @@ set_disk_and_part_name(struct device *de
                 set_disk_name(dev, "%s", ultimate);
                 set_part_name(dev, "%s%d", ultimate, dev->part);
                 debug("disk:%s part:%s%d", ultimate, ultimate, dev->part);
+		rc = 0;
         } else if (ultimate && approximate && !strcmp(approximate, "mtd")) {
                 /*
                  * 31:0 -> ../../devices/platform/1e000000.palmbus/1e000b00.spi/spi_master/spi32766/spi32766.0/mtd/mtd0/mtdblock0
                  */
                 set_disk_name(dev, "%s", ultimate);
                 debug("disk:%s", ultimate);
+		rc = 0;
         }
 
-        return 0;
+	if (rc < 0)
+		efi_error("Could not parse disk name:\"%s\"", dev->link);
+	return rc;
 }
 
 static struct dev_probe *dev_probes[] = {