Source
133
133
{
134
134
struct privcmd_buf_private *file_priv = file->private_data;
135
135
struct privcmd_buf_vma_private *vma_priv;
136
136
unsigned long count = vma_pages(vma);
137
137
unsigned int i;
138
138
int ret = 0;
139
139
140
140
if (!(vma->vm_flags & VM_SHARED))
141
141
return -EINVAL;
142
142
143
-
vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
144
-
GFP_KERNEL);
143
+
vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL);
145
144
if (!vma_priv)
146
145
return -ENOMEM;
147
146
148
147
for (i = 0; i < count; i++) {
149
148
vma_priv->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO);
150
149
if (!vma_priv->pages[i])
151
150
break;
152
151
vma_priv->n_pages++;
153
152
}
154
153