lkml.org 
[lkml]   [2020]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH 1/3] proc/meminfo: introduce extra meminfo
On (20/03/11 15:18), Sergey Senozhatsky wrote:
> On (20/03/11 12:44), Jaewon Kim wrote:
> [..]
> > +#define NAME_SIZE 15
> > +#define NAME_BUF_SIZE (NAME_SIZE + 2) /* ':' and '\0' */
> > +
> > +struct extra_meminfo {
> > + struct list_head list;
> > + atomic_long_t *val;
> > + int shift_for_page;
> > + char name[NAME_BUF_SIZE];
> > + char name_pad[NAME_BUF_SIZE];
> > +};
> > +
> > +int register_extra_meminfo(atomic_long_t *val, int shift, const char *name)
> > +{
> > + struct extra_meminfo *meminfo, *memtemp;
> > + int len;
> > + int error = 0;
> > +
> > + meminfo = kzalloc(sizeof(*meminfo), GFP_KERNEL);
> > + if (!meminfo) {
> > + error = -ENOMEM;
> > + goto out;
> > + }
> > +
> > + meminfo->val = val;
> > + meminfo->shift_for_page = shift;
> > + strncpy(meminfo->name, name, NAME_SIZE);
> > + len = strlen(meminfo->name);
> > + meminfo->name[len] = ':';
> > + strncpy(meminfo->name_pad, meminfo->name, NAME_BUF_SIZE);
>
> What happens if there is no NULL byte among the first NAME_SIZE bytes
> of passed `name'?

Ah. The buffer size is NAME_BUF_SIZE, so should be fine.

-ss

\
 
 \ /
  Last update: 2020-03-11 07:26    [W:0.096 / U:11.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site