diff --git a/lib/libefivar/efivar-dp-xlate.c b/lib/libefivar/efivar-dp-xlate.c index 58c89068645a..5c9398d9f43f 100644 --- a/lib/libefivar/efivar-dp-xlate.c +++ b/lib/libefivar/efivar-dp-xlate.c @@ -663,6 +663,7 @@ path_to_dp(struct gmesh *mesh, char *path, efidp *dp) free(rp); if (rv != 0) { free(*dp); + *dp = NULL; } return (rv); } diff --git a/usr.sbin/efidp/efidp.c b/usr.sbin/efidp/efidp.c index a4db95abeeac..e12491ecabf5 100644 --- a/usr.sbin/efidp/efidp.c +++ b/usr.sbin/efidp/efidp.c @@ -143,10 +143,13 @@ unix_to_efi(void) char *walker; int rv; + dp = NULL; while (fgets(buffer, sizeof(buffer), stdin)) { walker= trim(buffer); + free(dp); + dp = NULL; rv = efivar_unix_path_to_device_path(walker, &dp); - if (rv != 0) { + if (rv != 0 || dp == NULL) { errno = rv; warn("Can't convert '%s' to efi", walker); continue; @@ -158,6 +161,7 @@ unix_to_efi(void) } printf("%s\n", efi); } + free(dp); } static void