aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
authorOded Gabbay2022-05-11 10:06:39 +0300
committerGreg Kroah-Hartman2022-05-22 21:01:20 +0200
commit49d2a8af97a20d65d09ac85b57e525b32fdaa0e4 (patch)
treeaa91b3f23f28eb03393f3953d437f5e9092e5fb4 /drivers/misc
parent368b0b4fd6971b63ab9eb0a969b5847755d09493 (diff)
habanalabs: use NULL for eventfd
eventfd is pointer. As such, it should be initialized to NULL, not to 0. In addition, no need to initialize it after creation because the entire structure is zeroed-out. Also, no need to initialize it before release because the entire structure is freed. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/habanalabs/common/device.c8
-rw-r--r--drivers/misc/habanalabs/common/habanalabs_drv.c4
-rw-r--r--drivers/misc/habanalabs/common/habanalabs_ioctl.c4
3 files changed, 4 insertions, 12 deletions
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c
index 315510aaca35..0908ac301c70 100644
--- a/drivers/misc/habanalabs/common/device.c
+++ b/drivers/misc/habanalabs/common/device.c
@@ -286,10 +286,8 @@ static void hpriv_release(struct kref *ref)
hdev->compute_ctx_in_release = 0;
/* release the eventfd */
- if (hpriv->notifier_event.eventfd) {
+ if (hpriv->notifier_event.eventfd)
eventfd_ctx_put(hpriv->notifier_event.eventfd);
- hpriv->notifier_event.eventfd = 0;
- }
mutex_destroy(&hpriv->notifier_event.lock);
@@ -364,10 +362,8 @@ static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
mutex_unlock(&hdev->fpriv_ctrl_list_lock);
out:
/* release the eventfd */
- if (hpriv->notifier_event.eventfd) {
+ if (hpriv->notifier_event.eventfd)
eventfd_ctx_put(hpriv->notifier_event.eventfd);
- hpriv->notifier_event.eventfd = 0;
- }
mutex_destroy(&hpriv->notifier_event.lock);
put_pid(hpriv->taskpid);
diff --git a/drivers/misc/habanalabs/common/habanalabs_drv.c b/drivers/misc/habanalabs/common/habanalabs_drv.c
index c97173e9507d..9ead0927208d 100644
--- a/drivers/misc/habanalabs/common/habanalabs_drv.c
+++ b/drivers/misc/habanalabs/common/habanalabs_drv.c
@@ -134,8 +134,6 @@ int hl_device_open(struct inode *inode, struct file *filp)
hpriv->hdev = hdev;
filp->private_data = hpriv;
hpriv->filp = filp;
- hpriv->notifier_event.events_mask = 0;
- hpriv->notifier_event.eventfd = 0;
mutex_init(&hpriv->notifier_event.lock);
mutex_init(&hpriv->restore_phase_mutex);
@@ -246,8 +244,6 @@ int hl_device_open_ctrl(struct inode *inode, struct file *filp)
hpriv->hdev = hdev;
filp->private_data = hpriv;
hpriv->filp = filp;
- hpriv->notifier_event.events_mask = 0;
- hpriv->notifier_event.eventfd = 0;
mutex_init(&hpriv->notifier_event.lock);
nonseekable_open(inode, filp);
diff --git a/drivers/misc/habanalabs/common/habanalabs_ioctl.c b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
index d1ef56a8d3ac..51fa56287309 100644
--- a/drivers/misc/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/misc/habanalabs/common/habanalabs_ioctl.c
@@ -647,7 +647,7 @@ static int eventfd_register(struct hl_fpriv *hpriv, struct hl_info_args *args)
hpriv->notifier_event.eventfd = eventfd_ctx_fdget(args->eventfd);
if (IS_ERR(hpriv->notifier_event.eventfd)) {
rc = PTR_ERR(hpriv->notifier_event.eventfd);
- hpriv->notifier_event.eventfd = 0;
+ hpriv->notifier_event.eventfd = NULL;
mutex_unlock(&hpriv->notifier_event.lock);
return rc;
}
@@ -665,7 +665,7 @@ static int eventfd_unregister(struct hl_fpriv *hpriv, struct hl_info_args *args)
}
eventfd_ctx_put(hpriv->notifier_event.eventfd);
- hpriv->notifier_event.eventfd = 0;
+ hpriv->notifier_event.eventfd = NULL;
mutex_unlock(&hpriv->notifier_event.lock);
return 0;
}