linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: mathieu.poirier@linaro.org
Cc: bjorn.andersson@linaro.org, linmq006@gmail.com,
	linux-kernel@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	ohad@wizery.com
Subject: [PATCH v2] remoteproc: Fix NULL vs IS_ERR() checking in rproc_create_trace_file
Date: Wed,  5 Jan 2022 06:42:01 +0000	[thread overview]
Message-ID: <20220105064201.3907-1-linmq006@gmail.com> (raw)
In-Reply-To: <20220104174623.GA540353@p14s>

The debugfs_create_file() function doesn't return NULL.
It returns error pointers. Fix check in rproc_create_trace_file
and make it returns return error pointers.
Fix check in rproc_handle_trace propagate the error code.

Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
Changes in v2:
- return PTR_ERR(tfile) in rproc_create_trace_file
- fix check in rproc_handle_trace()
---
 drivers/remoteproc/remoteproc_core.c    | 6 ++++--
 drivers/remoteproc/remoteproc_debugfs.c | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 775df165eb45..5608408f8eac 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -656,6 +656,7 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr,
 	struct rproc_debug_trace *trace;
 	struct device *dev = &rproc->dev;
 	char name[15];
+	int ret;
 
 	if (sizeof(*rsc) > avail) {
 		dev_err(dev, "trace rsc is truncated\n");
@@ -684,9 +685,10 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr,
 
 	/* create the debugfs entry */
 	trace->tfile = rproc_create_trace_file(name, rproc, trace);
-	if (!trace->tfile) {
+	if (IS_ERR(trace->tfile)) {
+		ret = PTR_ERR(trace->tfile);
 		kfree(trace);
-		return -EINVAL;
+		return ret;
 	}
 
 	list_add_tail(&trace->node, &rproc->traces);
diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c
index b5a1e3b697d9..c1aa7272da1e 100644
--- a/drivers/remoteproc/remoteproc_debugfs.c
+++ b/drivers/remoteproc/remoteproc_debugfs.c
@@ -390,9 +390,9 @@ struct dentry *rproc_create_trace_file(const char *name, struct rproc *rproc,
 
 	tfile = debugfs_create_file(name, 0400, rproc->dbg_dir, trace,
 				    &trace_rproc_ops);
-	if (!tfile) {
+	if (IS_ERR(tfile)) {
 		dev_err(&rproc->dev, "failed to create debugfs trace entry\n");
-		return NULL;
+		return PTR_ERR(tfile);
 	}
 
 	return tfile;
-- 
2.17.1


  reply	other threads:[~2022-01-05  6:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27  9:06 [PATCH] remoteproc: Fix NULL vs IS_ERR() checking in rproc_create_trace_file Miaoqian Lin
2022-01-04 17:46 ` Mathieu Poirier
2022-01-05  6:42   ` Miaoqian Lin [this message]
2022-01-05 13:10     ` [PATCH v3] " Miaoqian Lin
2022-01-17 17:06       ` Mathieu Poirier
2022-01-17 22:31         ` Bjorn Andersson
2022-01-18 16:56           ` Mathieu Poirier
2022-01-18 19:17             ` Bjorn Andersson
2022-01-20 20:05               ` Mathieu Poirier

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=20220105064201.3907-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=ohad@wizery.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;
as well as URLs for NNTP newsgroup(s).