[virtmagma] fix pointer error checking
This change corrects the check for pointers returned from filp_open to
handle ERR_PTR values.
Change-Id: I6787f7b4d8840cd3b1475c9d91be890a29ddccad
diff --git a/drivers/virtio/virtio_magma.c b/drivers/virtio/virtio_magma.c
index 0a35ff8..7fcb871 100644
--- a/drivers/virtio/virtio_magma.c
+++ b/drivers/virtio/virtio_magma.c
@@ -637,14 +637,14 @@
instance->creator.comm[sizeof(instance->creator.comm) - 1] = 0;
filp = filp_open(WAYLAND_DEVICE_PATH, O_RDWR, 0);
- if (filp) {
- instance->wayland_device_private_data = filp->private_data;
- } else {
+ if (IS_ERR_OR_NULL(filp)) {
pr_warn("virtmagma: failed to open wayland device at %s\n",
WAYLAND_DEVICE_PATH);
pr_cont("virtmagma: magma_export will not be available\n");
+ } else {
+ instance->wayland_device_private_data = filp->private_data;
+ filp_close(filp, 0);
}
- filp_close(filp, 0);
instance->msg_cache =
kmem_cache_create("virtmagma_cache", MESSAGE_CACHE_OBJECT_SIZE,