All of lore.kernel.org
 help / color / mirror / Atom feed
From: naota@elisp.net
To: Joe Thornber <ejt@redhat.com>, dm-devel@redhat.com
Cc: Mike Snitzer <snitzer@redhat.com>,
	Alasdair Kergon <agk@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] dm: check era->md is non-NULL before closing it
Date: Tue, 20 May 2014 12:53:56 +0900	[thread overview]
Message-ID: <87d2f9ds17.fsf@elisp.net> (raw)

In era_ctr(), era->md remain NULL until it's set after metadata_open().
On the other hand, era_destroy() assume era->md is non-NULL and it is
called by era_ctr() before initializing the value.

This patch just checks if era->md is non-NULL.

Signed-off-by: Naohiro Aota <naota@elisp.net>
---
 drivers/md/dm-era-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index 414dad4..ad913cd 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -1391,7 +1391,8 @@ static int era_is_congested(struct dm_target_callbacks *cb, int bdi_bits)
 
 static void era_destroy(struct era *era)
 {
-	metadata_close(era->md);
+	if (era->md)
+		metadata_close(era->md);
 
 	if (era->wq)
 		destroy_workqueue(era->wq);
-- 
1.9.2

WARNING: multiple messages have this Message-ID (diff)
From: naota@elisp.net
To: Joe Thornber <ejt@redhat.com>, dm-devel@redhat.com
Cc: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] dm: check era->md is non-NULL before closing it
Date: Tue, 20 May 2014 12:53:56 +0900	[thread overview]
Message-ID: <87d2f9ds17.fsf@elisp.net> (raw)

In era_ctr(), era->md remain NULL until it's set after metadata_open().
On the other hand, era_destroy() assume era->md is non-NULL and it is
called by era_ctr() before initializing the value.

This patch just checks if era->md is non-NULL.

Signed-off-by: Naohiro Aota <naota@elisp.net>
---
 drivers/md/dm-era-target.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index 414dad4..ad913cd 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -1391,7 +1391,8 @@ static int era_is_congested(struct dm_target_callbacks *cb, int bdi_bits)
 
 static void era_destroy(struct era *era)
 {
-	metadata_close(era->md);
+	if (era->md)
+		metadata_close(era->md);
 
 	if (era->wq)
 		destroy_workqueue(era->wq);
-- 
1.9.2



             reply	other threads:[~2014-05-20  3:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-20  3:53 naota [this message]
2014-05-20  3:53 ` [PATCH] dm: check era->md is non-NULL before closing it naota
2014-05-20  7:41 ` Joe Thornber

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=87d2f9ds17.fsf@elisp.net \
    --to=naota@elisp.net \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ejt@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --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.