ivshmem: shell: Fix crashing when device is not ready
Fix crash when device is not ready but ivshmem is not NULL. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
ec98555f42
commit
f6d57e5210
1 changed files with 5 additions and 7 deletions
|
@ -8,7 +8,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <zephyr/drivers/virtualization/ivshmem.h>
|
||||
|
||||
static const struct device *ivshmem;
|
||||
static const struct device *ivshmem = DEVICE_DT_GET_ONE(qemu_ivshmem);
|
||||
|
||||
#ifdef CONFIG_IVSHMEM_DOORBELL
|
||||
|
||||
|
@ -48,14 +48,12 @@ static void doorbell_notification_thread(const struct shell *sh)
|
|||
|
||||
static bool get_ivshmem(const struct shell *sh)
|
||||
{
|
||||
if (ivshmem == NULL) {
|
||||
ivshmem = DEVICE_DT_GET_ONE(qemu_ivshmem);
|
||||
if (!device_is_ready(ivshmem)) {
|
||||
shell_error(sh, "IVshmem device is not ready");
|
||||
}
|
||||
if (!device_is_ready(ivshmem)) {
|
||||
shell_error(sh, "IVshmem device is not ready");
|
||||
return false;
|
||||
}
|
||||
|
||||
return ivshmem != NULL ? true : false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cmd_ivshmem_shmem(const struct shell *sh,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue