linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pan Bian <bianpan2016@163.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: [PATCH 1/1] misc: set error code when devm_kstrdup fails
Date: Sat,  3 Dec 2016 17:29:28 +0800	[thread overview]
Message-ID: <1480757368-3921-1-git-send-email-bianpan2016@163.com> (raw)

In function sram_reserve_regions(), the value of return variable ret
should be negative on failures. However, the value of ret may be 0 even
if the call to devm_kstrdup() returns a NULL pointer. This patch
explicitly assigns "-ENOMEM" to ret on the path that devm_kstrdup()
fails.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188651

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/misc/sram.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
index f84b53d..0ef7d65 100644
--- a/drivers/misc/sram.c
+++ b/drivers/misc/sram.c
@@ -244,8 +244,10 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
 
 			block->label = devm_kstrdup(sram->dev,
 						    label, GFP_KERNEL);
-			if (!block->label)
+			if (!block->label) {
+				ret = -ENOMEM;
 				goto err_chunks;
+			}
 
 			dev_dbg(sram->dev, "found %sblock '%s' 0x%x-0x%x\n",
 				block->export ? "exported " : "", block->label,
-- 
1.9.1

                 reply	other threads:[~2016-12-03  9:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1480757368-3921-1-git-send-email-bianpan2016@163.com \
    --to=bianpan2016@163.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).