Re: [PATCH v3 3/3] drivers/base/node.c: use bin_attribute to avoid buff overflow

From: Andy Shevchenko
Date: Thu Jun 03 2021 - 07:10:04 EST


On Thu, Jun 03, 2021 at 06:31:57PM +0800, tiantao (H) wrote:
> 在 2021/6/3 17:53, Andy Shevchenko 写道:
> > On Thu, Jun 03, 2021 at 05:22:42PM +0800, Tian Tao wrote:
> > > Reading sys/devices/system/cpu/cpuX/nodeX/ returns cpumap and cpulist.
> > > 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.
> > ...
> >
> > > }
> > > -static DEVICE_ATTR_RO(cpumap);
> > > -static inline ssize_t cpulist_show(struct device *dev,
> > > - struct device_attribute *attr,
> > > - char *buf)
> > > +static BIN_ATTR_RO(cpumap, 0);
> > So, you will have 2 blank lines in a row after this. Why one is not enough?
> > Same question for other similar cases, if any.
>
>  I can delete the line 55. this is the only problem, are there any other
> problems?

I don't know. I'm not familiar with the area.

--
With Best Regards,
Andy Shevchenko