mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-06 00:20:29 +00:00
Fail to open efirt device when no EFI on system.
libefivar expects opening /dev/efi to indicate if the we can make efi runtime calls. With a null routine, it was always succeeding leading efi_variables_supported() to return the wrong value. Only succeed if we have an efi_runtime table. Also, while I'm hear, out of an abundance of caution, add a likely redundant check to make sure efi_systbl is not NULL before dereferencing it. I know it can't be NULL if efi_cfgtbl is non-NULL, but the compiler doesn't.
This commit is contained in:
parent
ac0ced90e0
commit
9057f54d74
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322278
|
@ -420,13 +420,22 @@ efi_uninit(void)
|
||||||
mtx_destroy(&efi_lock);
|
mtx_destroy(&efi_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
efi_rt_ok(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (efi_runtime == NULL)
|
||||||
|
return (ENXIO);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
efi_get_table(struct uuid *uuid, void **ptr)
|
efi_get_table(struct uuid *uuid, void **ptr)
|
||||||
{
|
{
|
||||||
struct efi_cfgtbl *ct;
|
struct efi_cfgtbl *ct;
|
||||||
u_long count;
|
u_long count;
|
||||||
|
|
||||||
if (efi_cfgtbl == NULL)
|
if (efi_cfgtbl == NULL || efi_systbl == NULL)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
count = efi_systbl->st_entries;
|
count = efi_systbl->st_entries;
|
||||||
ct = efi_cfgtbl;
|
ct = efi_cfgtbl;
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
struct uuid;
|
struct uuid;
|
||||||
struct efi_tm;
|
struct efi_tm;
|
||||||
|
|
||||||
|
int efi_rt_ok(void);
|
||||||
int efi_get_table(struct uuid *uuid, void **ptr);
|
int efi_get_table(struct uuid *uuid, void **ptr);
|
||||||
int efi_get_time(struct efi_tm *tm);
|
int efi_get_time(struct efi_tm *tm);
|
||||||
int efi_get_time_locked(struct efi_tm *tm);
|
int efi_get_time_locked(struct efi_tm *tm);
|
||||||
|
|
|
@ -39,14 +39,27 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <machine/efi.h>
|
#include <machine/efi.h>
|
||||||
#include <sys/efiio.h>
|
#include <sys/efiio.h>
|
||||||
|
|
||||||
|
static d_open_t efidev_open;
|
||||||
static d_ioctl_t efidev_ioctl;
|
static d_ioctl_t efidev_ioctl;
|
||||||
|
|
||||||
static struct cdevsw efi_cdevsw = {
|
static struct cdevsw efi_cdevsw = {
|
||||||
.d_name = "efi",
|
.d_name = "efi",
|
||||||
.d_version = D_VERSION,
|
.d_version = D_VERSION,
|
||||||
|
.d_open = efidev_open,
|
||||||
.d_ioctl = efidev_ioctl,
|
.d_ioctl = efidev_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
efidev_open(struct cdev *dev __unused, int oflags __unused,
|
||||||
|
int devtype __unused, struct thread *td __unused)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Only return success when we have an actual runtime to call.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return efi_rt_ok();
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr,
|
efidev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr,
|
||||||
int flags __unused, struct thread *td __unused)
|
int flags __unused, struct thread *td __unused)
|
||||||
|
|
Loading…
Reference in a new issue