From: Dan Carpenter <dan.carpenter@oracle.com>
To: Shaohua Li <shli@kernel.org>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [patch v2] md/raid0: fix uninitialized variable bug
Date: Thu, 14 Apr 2016 09:31:49 +0000 [thread overview]
Message-ID: <20160414093149.GA16549@mwanda> (raw)
In-Reply-To: <20160413170240.GB6186@kernel.org>
If this function fails the callers expect that *private_conf is set to
an ERR_PTR() but that isn't true for the first error path where we can't
allocate "conf". It leads to some uninitialized variable bugs.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Shaohua suggested a different fix
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 2ea12c6..f63dbb6 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -85,6 +85,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
unsigned short blksize = 512;
+ *private_conf = ERR_PTR(-ENOMEM);
if (!conf)
return -ENOMEM;
rdev_for_each(rdev1, mddev) {
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Shaohua Li <shli@kernel.org>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [patch v2] md/raid0: fix uninitialized variable bug
Date: Thu, 14 Apr 2016 12:31:49 +0300 [thread overview]
Message-ID: <20160414093149.GA16549@mwanda> (raw)
In-Reply-To: <20160413170240.GB6186@kernel.org>
If this function fails the callers expect that *private_conf is set to
an ERR_PTR() but that isn't true for the first error path where we can't
allocate "conf". It leads to some uninitialized variable bugs.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Shaohua suggested a different fix
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 2ea12c6..f63dbb6 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -85,6 +85,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
unsigned short blksize = 512;
+ *private_conf = ERR_PTR(-ENOMEM);
if (!conf)
return -ENOMEM;
rdev_for_each(rdev1, mddev) {
next prev parent reply other threads:[~2016-04-14 9:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 6:46 [patch] md/raid0: check for create_strip_zones() errors Dan Carpenter
2016-04-13 6:46 ` Dan Carpenter
2016-04-13 17:02 ` Shaohua Li
2016-04-13 17:02 ` Shaohua Li
2016-04-13 17:53 ` Dan Carpenter
2016-04-13 17:53 ` Dan Carpenter
2016-04-14 9:31 ` Dan Carpenter [this message]
2016-04-14 9:31 ` [patch v2] md/raid0: fix uninitialized variable bug Dan Carpenter
2016-04-14 16:57 ` Shaohua Li
2016-04-14 16:57 ` Shaohua Li
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=20160414093149.GA16549@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=shli@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 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.