From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9610C433EF for ; Tue, 12 Oct 2021 19:01:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9624B610CE for ; Tue, 12 Oct 2021 19:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233581AbhJLTDH (ORCPT ); Tue, 12 Oct 2021 15:03:07 -0400 Received: from leibniz.telenet-ops.be ([195.130.137.77]:37660 "EHLO leibniz.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235356AbhJLTDH (ORCPT ); Tue, 12 Oct 2021 15:03:07 -0400 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by leibniz.telenet-ops.be (Postfix) with ESMTPS id 4HTPSF3mN3zMqg55 for ; Tue, 12 Oct 2021 20:33:33 +0200 (CEST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed20:9c93:91ff:d58:ecfb]) by baptiste.telenet-ops.be with bizsmtp id 56ZX2600A0KW32a016ZXZC; Tue, 12 Oct 2021 20:33:33 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1maMag-004RTr-Sa; Tue, 12 Oct 2021 20:33:30 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1maMaf-002j5w-Qn; Tue, 12 Oct 2021 20:33:29 +0200 From: Geert Uytterhoeven To: Miguel Ojeda Cc: Robin van der Gracht , Rob Herring , Paul Burton , Greg Kroah-Hartman , Pavel Machek , Marek Behun , devicetree@vger.kernel.org, linux-leds@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v7 07/21] auxdisplay: linedisp: Use kmemdup_nul() helper Date: Tue, 12 Oct 2021 20:33:13 +0200 Message-Id: <20211012183327.649865-8-geert@linux-m68k.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012183327.649865-1-geert@linux-m68k.org> References: <20211012183327.649865-1-geert@linux-m68k.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Use the existing kmemdup_nul() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven --- v7: - No changes, v6: - No changes, v5: - No changes, v4: - No changes, v3: - No changes, v2: - No changes. --- drivers/auxdisplay/line-display.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c index 4b97c20ac0b381ee..3f35199bc39f511f 100644 --- a/drivers/auxdisplay/line-display.c +++ b/drivers/auxdisplay/line-display.c @@ -91,13 +91,10 @@ static int linedisp_display(struct linedisp *linedisp, const char *msg, return 0; } - new_msg = kmalloc(count + 1, GFP_KERNEL); + new_msg = kmemdup_nul(msg, count, GFP_KERNEL); if (!new_msg) return -ENOMEM; - memcpy(new_msg, msg, count); - new_msg[count] = 0; - kfree(linedisp->message); linedisp->message = new_msg; -- 2.25.1