uipc_shm: Handle offset on shm_size as if it is beyond shm_size

This avoids any unnecessary works in such case.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	markj, kib
Differential Revision:	https://reviews.freebsd.org/D31655
This commit is contained in:
Ka Ho Ng 2021-08-24 22:39:43 +08:00
parent c12118f6ce
commit 5c1428d2c4

View File

@ -1915,8 +1915,8 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags)
pi = OFF_TO_IDX(off + PAGE_MASK);
error = 0;
/* Handle the case when offset is beyond shm size */
if ((off_t)len < 0) {
/* Handle the case when offset is on or beyond shm size. */
if ((off_t)len <= 0) {
*offset = shmfd->shm_size;
*length = 0;
return (0);