Re: [PATCH] relay: avoid relay_open_buf inproperly fails in buffer-only mode

From: Philo Lu
Date: Thu Mar 14 2024 - 23:23:14 EST




On 2024/3/15 10:39, zhangzhengming wrote:
diff --git a/kernel/relay.c b/kernel/relay.c
index a8e90e98bf2c..0d8b8325530a 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -391,12 +391,13 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
goto free_buf;
relay_set_buf_dentry(buf, dentry);
} else {
- /* Only retrieve global info, nothing more, nothing less */
+ /* In buffer-only mode, relay_open_buf is called with
+ * filename=NULL, but create_buf_file is still needed to
+ * retrieve is_global info. So dentry should be NULL here.
+ */
dentry = chan->cb->create_buf_file(NULL, NULL,
S_IRUSR, buf,
&chan->is_global);
- if (IS_ERR_OR_NULL(dentry))
- goto free_buf;
}
buf->cpu = cpu;
I suggest replacing IS_ERR_OR_NULL with IS_ERR instead of removing it due to the possibility of create_buf_file callback returning an error.


This would be fine. AFAICT the return value here is un-important. So reverting to `WARN_ON(dentry)` maybe another choice.