Re: [PATCH v2 2/3] topology: use bin_attribute to avoid buff overflow

From: Andy Shevchenko
Date: Wed Jun 02 2021 - 11:49:46 EST


On Wed, Jun 02, 2021 at 09:48:53PM +0800, Tian Tao wrote:
> Reading sys/devices/system/cpu/cpuX/topology/ returns cpu topology.
> However, the size of this file is limited to PAGE_SIZE because of the
> limitation for sysfs attribute. so we use bin_attribute instead of
> attribute to avoid NR_CPUS too big to cause buff overflow.

> This patch is based on the following discussion.
> https://lore.kernel.org/lkml/20210319041618.14316-2-song.bao.hua@xxxxxxxxxxxxx/

Link: tag?

...

> +static struct bin_attribute *bin_attrs[] = {
> + &bin_attr_core_cpus,
> + &bin_attr_core_cpus_list,
> + &bin_attr_thread_siblings,
> + &bin_attr_thread_siblings_list,
> + &bin_attr_core_siblings,
> + &bin_attr_core_siblings_list,
> + &bin_attr_die_cpus,
> + &bin_attr_die_cpus_list,
> + &bin_attr_package_cpus,
> + &bin_attr_package_cpus_list,
> +#ifdef CONFIG_SCHED_BOOK
> + &bin_attr_book_siblings,
> + &bin_attr_book_siblings_list,
> +#endif
> +#ifdef CONFIG_SCHED_DRAWER
> + &bin_attr_drawer_siblings,
> + &bin_attr_drawer_siblings_list,
> +#endif

> + NULL,

No comma for terminator line.

> +};

--
With Best Regards,
Andy Shevchenko