Re: [PATCH] remoteproc: Fix NULL vs IS_ERR() checking in rproc_create_trace_file

From: Mathieu Poirier
Date: Tue Jan 04 2022 - 12:46:29 EST


Good morning,

On Mon, Dec 27, 2021 at 09:06:45AM +0000, Miaoqian Lin wrote:
> The debugfs_create_file() function doesn't return NULL.
> It returns error pointers.

You are correct.

>
> Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx>
> ---
> drivers/remoteproc/remoteproc_debugfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_debugfs.c b/drivers/remoteproc/remoteproc_debugfs.c
> index b5a1e3b697d9..a2409fe2f57b 100644
> --- a/drivers/remoteproc/remoteproc_debugfs.c
> +++ b/drivers/remoteproc/remoteproc_debugfs.c
> @@ -390,7 +390,7 @@ 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;

Please return PTR_ERR(tfile) and fix rproc_handle_trace() to do the right error
check and propagate the error code if needed.

Thanks,
Mathieu

> }
> --
> 2.17.1
>