lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZFPDYwa8ko6ZUEEL@smile.fi.intel.com>
Date:   Thu, 4 May 2023 17:38:27 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     "Peng Fan (OSS)" <peng.fan@....nxp.com>
Cc:     gregkh@...uxfoundation.org, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, rafael@...nel.org,
        hdegoede@...hat.com, jgg@...pe.ca, saravanak@...gle.com,
        keescook@...omium.org, tglx@...utronix.de,
        linux-kernel@...r.kernel.org, abel.vesa@...aro.org,
        Peng Fan <peng.fan@....com>
Subject: Re: [PATCH] devres: provide API devm_kstrndup

On Thu, May 04, 2023 at 03:57:54PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@....com>
> 
> This patch introduces devm_kstrndup API so that the
> device's driver can allocate memory and copy string.

...

> +char *devm_kstrndup(struct device *dev, const char *s, size_t max, gfp_t gfp)
> +{
> +	size_t len;
> +	char *buf;
> +
> +	if (!s)
> +		return NULL;
> +
> +	len = strnlen(s, max);

> +	buf = devm_kmalloc(dev, len + 1, gfp);
> +	if (buf) {
> +		memcpy(buf, s, len);

besides this to be open coded devm_kmemdup()

> +		buf[len] = '\0';
> +	}
> +	return buf;
> +}

you can always use devm_add_action_or_reset() for a single user before
we introduce a new wide API.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ