Skip to content

Commit

Permalink
relay: require non-NULL callbacks in relay_open()
Browse files Browse the repository at this point in the history
There are no clients passing NULL callbacks, which makes sense as it
wouldn't even create a file.  Require non-NULL callbacks, and throw away
the handling for NULL callbacks.

Link: https://lkml.kernel.org/r/e40642f3b027d2bb6bc851ddb60e0a61ea51f5f8.1606153547.git.jani.nikula@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Suggested-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jani Nikula authored and Linus Torvalds committed Dec 16, 2020
1 parent 3d03295 commit 6f8f254
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions kernel/relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,6 @@ static int remove_buf_file_default_callback(struct dentry *dentry)
return -EINVAL;
}

/* relay channel default callbacks */
static struct rchan_callbacks default_channel_callbacks = {
.subbuf_start = subbuf_start_default_callback,
.create_buf_file = create_buf_file_default_callback,
.remove_buf_file = remove_buf_file_default_callback,
};

/**
* wakeup_readers - wake up readers waiting on a channel
* @work: contains the channel buffer
Expand Down Expand Up @@ -472,11 +465,6 @@ static void relay_close_buf(struct rchan_buf *buf)
static void setup_callbacks(struct rchan *chan,
struct rchan_callbacks *cb)
{
if (!cb) {
chan->cb = &default_channel_callbacks;
return;
}

if (!cb->subbuf_start)
cb->subbuf_start = subbuf_start_default_callback;
if (!cb->create_buf_file)
Expand Down Expand Up @@ -542,6 +530,8 @@ struct rchan *relay_open(const char *base_filename,
return NULL;
if (subbuf_size > UINT_MAX / n_subbufs)
return NULL;
if (!cb)
return NULL;

chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
if (!chan)
Expand Down

0 comments on commit 6f8f254

Please sign in to comment.