All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>, linux-kernel@vger.kernel.org
Subject: [PATCH RESEND] parport: replace kmalloc + strcpy with kstrdup in parse_data
Date: Mon, 18 May 2026 18:48:04 +0200	[thread overview]
Message-ID: <20260518164803.81003-2-thorsten.blum@linux.dev> (raw)

Replace kmalloc() followed by strcpy() with a single call to kstrdup()
to simplify parse_data().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/parport/probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index 5d1b9aacb130..bf9d81c0abaf 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -52,7 +52,7 @@ static void pretty_print(struct parport *port, int device)
 
 static void parse_data(struct parport *port, int device, char *str)
 {
-	char *txt = kmalloc(strlen(str)+1, GFP_KERNEL);
+	char *txt = kstrdup(str, GFP_KERNEL);
 	char *p = txt, *q;
 	int guessed_class = PARPORT_CLASS_UNSPEC;
 	struct parport_device_info *info = &port->probe_info[device + 1];
@@ -61,7 +61,6 @@ static void parse_data(struct parport *port, int device, char *str)
 		pr_warn("%s probe: memory squeeze\n", port->name);
 		return;
 	}
-	strcpy(txt, str);
 	while (p) {
 		char *sep;
 		q = strchr(p, ';');

             reply	other threads:[~2026-05-18 16:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 16:48 Thorsten Blum [this message]
2026-06-04 15:22 ` [PATCH RESEND] parport: replace kmalloc + strcpy with kstrdup in parse_data Thorsten Blum
  -- strict thread matches above, loose matches on Subject: below --
2026-05-04 18:10 Thorsten Blum

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=20260518164803.81003-2-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.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 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.