All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aliaksei Karaliou <akaraliou.dev@gmail.com>
To: agk@redhat.com, snitzer@redhat.com
Cc: dm-devel@redhat.com, Aliaksei Karaliou <akaraliou.dev@gmail.com>
Subject: [PATCH 2/2] dm bufio: check result of register_shrinker()
Date: Sat, 23 Dec 2017 13:27:04 +0300	[thread overview]
Message-ID: <20171223102704.3087-2-akaraliou.dev@gmail.com> (raw)
In-Reply-To: <20171223102704.3087-1-akaraliou.dev@gmail.com>

dm_bufio_client_create() does not check result of register_shrinker()
which was tagged as __must_check recently, reported by sparse.

Signed-off-by: Aliaksei Karaliou <akaraliou.dev@gmail.com>
---
 drivers/md/dm-bufio.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 1c661d4c211c..8f3ccf88951e 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1743,20 +1743,23 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
 		__free_buffer_wake(b);
 	}
 
+	c->shrinker.count_objects = dm_bufio_shrink_count;
+	c->shrinker.scan_objects = dm_bufio_shrink_scan;
+	c->shrinker.seeks = 1;
+	c->shrinker.batch = 0;
+	r = register_shrinker(&c->shrinker);
+	if (r)
+		goto bad_shrinker;
+
 	mutex_lock(&dm_bufio_clients_lock);
 	dm_bufio_client_count++;
 	list_add(&c->client_list, &dm_bufio_all_clients);
 	__cache_size_refresh();
 	mutex_unlock(&dm_bufio_clients_lock);
 
-	c->shrinker.count_objects = dm_bufio_shrink_count;
-	c->shrinker.scan_objects = dm_bufio_shrink_scan;
-	c->shrinker.seeks = 1;
-	c->shrinker.batch = 0;
-	register_shrinker(&c->shrinker);
-
 	return c;
 
+bad_shrinker:
 bad_buffer:
 bad_cache:
 	while (!list_empty(&c->reserved_buffers)) {
-- 
2.11.0

      reply	other threads:[~2017-12-23 10:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-23 10:27 [PATCH 1/2] dm bufio: add missed destroy of client's mutex Aliaksei Karaliou
2017-12-23 10:27 ` Aliaksei Karaliou [this message]

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=20171223102704.3087-2-akaraliou.dev@gmail.com \
    --to=akaraliou.dev@gmail.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=snitzer@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.