linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Shuah Khan <shuahkh@osg.samsung.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ming Lei <ming.lei@canonical.com>
Cc: Kees Cook <keescook@chromium.org>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	"Luis R. Rodriguez" <mcgrof@suse.com>
Subject: [PATCH v2 2/5] test: firmware_class: use kstrndup() where appropriate
Date: Wed,  9 Dec 2015 14:50:26 -0800	[thread overview]
Message-ID: <1449701429-121423-2-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com>

We're essentially just doing an open-coded kstrndup(). The only
differences are with what happens after the first '\0' character, but
request_firmware() doesn't care about that.

Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
New in v2

 lib/test_firmware.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 841191061816..690b9c35a274 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -54,10 +54,9 @@ static ssize_t trigger_request_store(struct device *dev,
 	int rc;
 	char *name;
 
-	name = kzalloc(count + 1, GFP_KERNEL);
+	name = kstrndup(buf, count, GFP_KERNEL);
 	if (!name)
 		return -ENOSPC;
-	memcpy(name, buf, count);
 
 	pr_info("loading '%s'\n", name);
 
-- 
2.6.0.rc2.230.g3dd15c0

  reply	other threads:[~2015-12-09 22:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 22:50 [PATCH v2 1/5] test: firmware_class: report errors properly on failure Brian Norris
2015-12-09 22:50 ` Brian Norris [this message]
     [not found]   ` <1449701429-121423-2-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-07 20:55     ` [PATCH v2 2/5] test: firmware_class: use kstrndup() where appropriate Shuah Khan
2015-12-09 22:50 ` [PATCH v2 3/5] test: firmware_class: add asynchronous request trigger Brian Norris
     [not found]   ` <1449701429-121423-3-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-12-09 23:22     ` Kees Cook
2016-01-07 20:56   ` Shuah Khan
2015-12-09 22:50 ` [PATCH v2 4/5] firmware: actually return NULL on failed request_firmware_nowait() Brian Norris
2015-12-21 19:06   ` Luis R. Rodriguez
     [not found]   ` <1449701429-121423-4-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-07 20:56     ` Shuah Khan
2015-12-09 22:50 ` [PATCH v2 5/5] selftests: firmware: add empty string and async tests Brian Norris
     [not found]   ` <1449701429-121423-5-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-07 20:57     ` Shuah Khan
     [not found]       ` <568ED136.40308-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>
2016-01-07 21:39         ` Brian Norris
     [not found]           ` <20160107213953.GA49009-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2016-01-07 21:42             ` Shuah Khan
     [not found] ` <1449701429-121423-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-01-07 20:54   ` [PATCH v2 1/5] test: firmware_class: report errors properly on failure Shuah Khan

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=1449701429-121423-2-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@suse.com \
    --cc=ming.lei@canonical.com \
    --cc=shuahkh@osg.samsung.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 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).