mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oded Gabbay <ogabbay@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: kernel test robot <lkp@intel.com>
Subject: [PATCH 2/3] habanalabs: use NULL for eventfd
Date: Wed, 11 May 2022 16:19:47 +0300	[thread overview]
Message-ID: <20220511131948.1156471-2-ogabbay@kernel.org> (raw)
In-Reply-To: <20220511131948.1156471-1-ogabbay@kernel.org>

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>
---
 drivers/misc/habanalabs/common/device.c           | 8 ++------
 drivers/misc/habanalabs/common/habanalabs_drv.c   | 4 ----
 drivers/misc/habanalabs/common/habanalabs_ioctl.c | 4 ++--
 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;
 }
-- 
2.25.1


  reply	other threads:[~2022-05-11 13:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 13:19 [PATCH 1/3] habanalabs: update firmware header Oded Gabbay
2022-05-11 13:19 ` Oded Gabbay [this message]
2022-05-11 13:19 ` [PATCH 3/3] habanalabs: return -EFAULT on copy_to_user error Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220511131948.1156471-2-ogabbay@kernel.org \
    --to=ogabbay@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome