mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	intel-gfx@lists.freedesktop.org, jani.nikula@intel.com
Subject: [PATCH 2/9] relay: require non-NULL callbacks in relay_open()
Date: Mon, 23 Nov 2020 19:59:22 +0200	[thread overview]
Message-ID: <e40642f3b027d2bb6bc851ddb60e0a61ea51f5f8.1606153547.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1606153547.git.jani.nikula@intel.com>

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.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 kernel/relay.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/kernel/relay.c b/kernel/relay.c
index b51343642bf4..d9b8185161a8 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -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
@@ -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)
@@ -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)
-- 
2.20.1


  parent reply	other threads:[~2020-11-23 18:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 17:59 [PATCH 0/9] relay: cleanup and const callbacks, take 2 Jani Nikula
2020-11-23 17:59 ` [PATCH 1/9] relay: remove unused buf_mapped and buf_unmapped callbacks Jani Nikula
2020-11-24  9:37   ` Christoph Hellwig
2020-11-23 17:59 ` Jani Nikula [this message]
2020-11-24  9:37   ` [PATCH 2/9] relay: require non-NULL callbacks in relay_open() Christoph Hellwig
2020-11-23 17:59 ` [PATCH 3/9] relay: make create_buf_file and remove_buf_file callbacks mandatory Jani Nikula
2020-11-24  9:37   ` Christoph Hellwig
2020-11-23 17:59 ` [PATCH 4/9] relay: allow the use of const callback structs Jani Nikula
2020-11-24  9:42   ` Christoph Hellwig
2020-11-24 11:54     ` [PATCH v3] " Jani Nikula
2020-11-24 11:56     ` [PATCH 4/9] " Jani Nikula
2020-11-23 17:59 ` [PATCH 5/9] drm/i915: make relay callbacks const Jani Nikula
2020-11-24  9:42   ` Christoph Hellwig
2020-11-23 17:59 ` [PATCH 6/9] ath10k: " Jani Nikula
2020-11-24  9:42   ` Christoph Hellwig
2020-11-23 17:59 ` [PATCH 7/9] ath11k: " Jani Nikula
2020-11-24  9:42   ` Christoph Hellwig
2020-11-23 17:59 ` [PATCH 8/9] ath9k: " Jani Nikula
2020-11-24  9:42   ` Christoph Hellwig
2020-11-23 17:59 ` [PATCH 9/9] blktrace: " Jani Nikula
2020-11-24  9:43   ` Christoph Hellwig
2020-11-23 18:06 ` [PATCH 0/9] relay: cleanup and const callbacks, take 2 Kalle Valo

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=e40642f3b027d2bb6bc851ddb60e0a61ea51f5f8.1606153547.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®