diff options
Diffstat (limited to 'ipc/shm.c')
-rw-r--r-- | ipc/shm.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -174,7 +174,7 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) | |||
174 | shm_unlock(shp); | 174 | shm_unlock(shp); |
175 | if (!is_file_hugepages(shp->shm_file)) | 175 | if (!is_file_hugepages(shp->shm_file)) |
176 | shmem_lock(shp->shm_file, 0, shp->mlock_user); | 176 | shmem_lock(shp->shm_file, 0, shp->mlock_user); |
177 | else | 177 | else if (shp->mlock_user) |
178 | user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size, | 178 | user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size, |
179 | shp->mlock_user); | 179 | shp->mlock_user); |
180 | fput (shp->shm_file); | 180 | fput (shp->shm_file); |
@@ -369,8 +369,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) | |||
369 | /* hugetlb_file_setup applies strict accounting */ | 369 | /* hugetlb_file_setup applies strict accounting */ |
370 | if (shmflg & SHM_NORESERVE) | 370 | if (shmflg & SHM_NORESERVE) |
371 | acctflag = VM_NORESERVE; | 371 | acctflag = VM_NORESERVE; |
372 | file = hugetlb_file_setup(name, size, acctflag); | 372 | file = hugetlb_file_setup(name, size, acctflag, |
373 | shp->mlock_user = current_user(); | 373 | &shp->mlock_user); |
374 | } else { | 374 | } else { |
375 | /* | 375 | /* |
376 | * Do not allow no accounting for OVERCOMMIT_NEVER, even | 376 | * Do not allow no accounting for OVERCOMMIT_NEVER, even |
@@ -410,6 +410,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) | |||
410 | return error; | 410 | return error; |
411 | 411 | ||
412 | no_id: | 412 | no_id: |
413 | if (shp->mlock_user) /* shmflg & SHM_HUGETLB case */ | ||
414 | user_shm_unlock(size, shp->mlock_user); | ||
413 | fput(file); | 415 | fput(file); |
414 | no_file: | 416 | no_file: |
415 | security_shm_free(shp); | 417 | security_shm_free(shp); |