diff options
Diffstat (limited to 'drivers/lguest/lguest_user.c')
-rw-r--r-- | drivers/lguest/lguest_user.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c index 816d4d12a801..5632ed82798a 100644 --- a/drivers/lguest/lguest_user.c +++ b/drivers/lguest/lguest_user.c | |||
@@ -167,11 +167,11 @@ static int initialize(struct file *file, const u32 __user *input) | |||
167 | /* "struct lguest" contains everything we (the Host) know about a | 167 | /* "struct lguest" contains everything we (the Host) know about a |
168 | * Guest. */ | 168 | * Guest. */ |
169 | struct lguest *lg; | 169 | struct lguest *lg; |
170 | int err, i; | 170 | int err; |
171 | u32 args[5]; | 171 | u32 args[5]; |
172 | 172 | ||
173 | /* We grab the Big Lguest lock, which protects the global array | 173 | /* We grab the Big Lguest lock, which protects against multiple |
174 | * "lguests" and multiple simultaneous initializations. */ | 174 | * simultaneous initializations. */ |
175 | mutex_lock(&lguest_lock); | 175 | mutex_lock(&lguest_lock); |
176 | /* You can't initialize twice! Close the device and start again... */ | 176 | /* You can't initialize twice! Close the device and start again... */ |
177 | if (file->private_data) { | 177 | if (file->private_data) { |
@@ -184,18 +184,13 @@ static int initialize(struct file *file, const u32 __user *input) | |||
184 | goto unlock; | 184 | goto unlock; |
185 | } | 185 | } |
186 | 186 | ||
187 | /* Find an unused guest. */ | 187 | lg = kzalloc(sizeof(*lg), GFP_KERNEL); |
188 | i = find_free_guest(); | 188 | if (!lg) { |
189 | if (i < 0) { | 189 | err = -ENOMEM; |
190 | err = -ENOSPC; | ||
191 | goto unlock; | 190 | goto unlock; |
192 | } | 191 | } |
193 | /* OK, we have an index into the "lguest" array: "lg" is a convenient | ||
194 | * pointer. */ | ||
195 | lg = &lguests[i]; | ||
196 | 192 | ||
197 | /* Populate the easy fields of our "struct lguest" */ | 193 | /* Populate the easy fields of our "struct lguest" */ |
198 | lg->guestid = i; | ||
199 | lg->mem_base = (void __user *)(long)args[0]; | 194 | lg->mem_base = (void __user *)(long)args[0]; |
200 | lg->pfn_limit = args[1]; | 195 | lg->pfn_limit = args[1]; |
201 | lg->page_offset = args[4]; | 196 | lg->page_offset = args[4]; |