Re: [PATCH v3 2/3] ACPI: property: Add acpi_fwnode_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 26, 2018 at 02:47:51PM +0300, Heikki Krogerus wrote:
> This implements the get_name fwnode op for ACPI.

> +static int
> +acpi_fwnode_get_name(const struct fwnode_handle *fwnode, char *buf, size_t len)
> +{
> +	struct acpi_buffer buffer;
> +	acpi_handle handle;
> +	acpi_status status;
> +
> +	if (is_acpi_data_node(fwnode)) {
> +		snprintf(buf, len, "%s", to_acpi_data_node(fwnode)->name);

Same question as per patch 1. How are we going to handle bigger strings?

> +		return 0;
> +	}
> +
> +	handle = to_acpi_device_node(fwnode)->handle;
> +

> +	buffer.length = min((size_t)ACPI_NAME_SIZE + 1, len);

Hmm...

 min_t(size_t, ...) ?


> +	buffer.pointer = buf;
> +
> +	status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);

And same question here. Is it possible to get length of the name and check?

Perhaps, I would return -ENAMETOOLONG (-EOVERFLOW) or alike for such cases.

> +	if (ACPI_FAILURE(status))
> +		return -ENXIO;
> +	return 0;
> +}

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux