From: Raag Jadav <raag.jadav@intel.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
andriy.shevchenko@linux.intel.com
Cc: linux-kernel@vger.kernel.org, Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v1] devres: simplify devm_kstrdup() using devm_kmemdup()
Date: Mon, 7 Apr 2025 17:43:11 +0530 [thread overview]
Message-ID: <20250407121311.1702521-1-raag.jadav@intel.com> (raw)
devm_kstrdup() logic pretty much reflects devm_kmemdup() for strings,
so just reuse it.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
drivers/base/devres.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index d8a733ea5e1a..82fdc1c55045 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -976,17 +976,7 @@ EXPORT_SYMBOL_GPL(devm_krealloc);
*/
char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp)
{
- size_t size;
- char *buf;
-
- if (!s)
- return NULL;
-
- size = strlen(s) + 1;
- buf = devm_kmalloc(dev, size, gfp);
- if (buf)
- memcpy(buf, s, size);
- return buf;
+ return s ? devm_kmemdup(dev, s, strlen(s) + 1, gfp) : NULL;
}
EXPORT_SYMBOL_GPL(devm_kstrdup);
--
2.34.1
next reply other threads:[~2025-04-07 12:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 12:13 Raag Jadav [this message]
2025-04-07 13:40 ` Andy Shevchenko
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=20250407121311.1702521-1-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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
all inboxes | Powered by JetHome®