|
21 | 21 |
|
22 | 22 | MODULE_LICENSE("GPL");
|
23 | 23 |
|
24 |
| -static unsigned int limit = 64; |
25 |
| -module_param(limit, uint, 0644); |
26 |
| -MODULE_PARM_DESC(limit, "Maximum number of pages that may be allocated by " |
27 |
| - "the privcmd-buf device per open file"); |
28 |
| - |
29 | 24 | struct privcmd_buf_private {
|
30 | 25 | struct mutex lock;
|
31 | 26 | struct list_head list;
|
32 |
| - unsigned int allocated; |
33 | 27 | };
|
34 | 28 |
|
35 | 29 | struct privcmd_buf_vma_private {
|
@@ -60,13 +54,10 @@ static void privcmd_buf_vmapriv_free(struct privcmd_buf_vma_private *vma_priv)
|
60 | 54 | {
|
61 | 55 | unsigned int i;
|
62 | 56 |
|
63 |
| - vma_priv->file_priv->allocated -= vma_priv->n_pages; |
64 |
| - |
65 | 57 | list_del(&vma_priv->list);
|
66 | 58 |
|
67 | 59 | for (i = 0; i < vma_priv->n_pages; i++)
|
68 |
| - if (vma_priv->pages[i]) |
69 |
| - __free_page(vma_priv->pages[i]); |
| 60 | + __free_page(vma_priv->pages[i]); |
70 | 61 |
|
71 | 62 | kfree(vma_priv);
|
72 | 63 | }
|
@@ -146,28 +137,23 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
|
146 | 137 | unsigned int i;
|
147 | 138 | int ret = 0;
|
148 | 139 |
|
149 |
| - if (!(vma->vm_flags & VM_SHARED) || count > limit || |
150 |
| - file_priv->allocated + count > limit) |
| 140 | + if (!(vma->vm_flags & VM_SHARED)) |
151 | 141 | return -EINVAL;
|
152 | 142 |
|
153 | 143 | vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
|
154 | 144 | GFP_KERNEL);
|
155 | 145 | if (!vma_priv)
|
156 | 146 | return -ENOMEM;
|
157 | 147 |
|
158 |
| - vma_priv->n_pages = count; |
159 |
| - count = 0; |
160 |
| - for (i = 0; i < vma_priv->n_pages; i++) { |
| 148 | + for (i = 0; i < count; i++) { |
161 | 149 | vma_priv->pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
162 | 150 | if (!vma_priv->pages[i])
|
163 | 151 | break;
|
164 |
| - count++; |
| 152 | + vma_priv->n_pages++; |
165 | 153 | }
|
166 | 154 |
|
167 | 155 | mutex_lock(&file_priv->lock);
|
168 | 156 |
|
169 |
| - file_priv->allocated += count; |
170 |
| - |
171 | 157 | vma_priv->file_priv = file_priv;
|
172 | 158 | vma_priv->users = 1;
|
173 | 159 |
|
|
0 commit comments