Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753980AbbLIWu7 (ORCPT ); Wed, 9 Dec 2015 17:50:59 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35405 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753482AbbLIWu4 (ORCPT ); Wed, 9 Dec 2015 17:50:56 -0500 From: Brian Norris To: Shuah Khan , Greg Kroah-Hartman , Ming Lei Cc: Kees Cook , Brian Norris , , , "Luis R. Rodriguez" Subject: [PATCH v2 2/5] test: firmware_class: use kstrndup() where appropriate Date: Wed, 9 Dec 2015 14:50:26 -0800 Message-Id: <1449701429-121423-2-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> References: <1449701429-121423-1-git-send-email-computersforpeace@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1083 Lines: 36 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 Signed-off-by: Brian Norris --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/