aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-25 21:03:56 +0200
committerBrian Behlendorf <[email protected]>2021-06-03 13:17:49 -0700
commite00aae4be2b5f126eb67ff3cdfd1b8e09e99fc0b (patch)
treeb080fe10f528a8a1a2f22ce223479dd9a018ac2b /lib
parenteefaa55f6452dcaeb26a8994ecf6aa8af054ab83 (diff)
libefi: efi_get_devname: don't allocate procfs path
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Reviewed-by: John Kennedy <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12048
Diffstat (limited to 'lib')
-rw-r--r--lib/libefi/rdwr_efi.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/libefi/rdwr_efi.c b/lib/libefi/rdwr_efi.c
index ca7a760b6..1e022cc8e 100644
--- a/lib/libefi/rdwr_efi.c
+++ b/lib/libefi/rdwr_efi.c
@@ -218,22 +218,15 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize)
static char *
efi_get_devname(int fd)
{
- char *path;
- char *dev_name;
-
- path = calloc(1, PATH_MAX);
- if (path == NULL)
- return (NULL);
+ char path[32];
/*
* The libefi API only provides the open fd and not the file path.
* To handle this realpath(3) is used to resolve the block device
* name from /proc/self/fd/<fd>.
*/
- (void) sprintf(path, "/proc/self/fd/%d", fd);
- dev_name = realpath(path, NULL);
- free(path);
- return (dev_name);
+ (void) snprintf(path, sizeof (path), "/proc/self/fd/%d", fd);
+ return (realpath(path, NULL));
}
static int