Skip to content

Commit 7f27117

Browse files
committed
memory/patcher: fix coverity warning
Fix CID 1358512: Error handling issues (NEGATIVE_RETURNS): C libraries usually handle read (-1, ...) fine but it is safer to avoid calling read with a negative handle. Added negative file descriptor check. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent d969196 commit 7f27117

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

opal/mca/memory/patcher/memory_patcher_component.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ static size_t memory_patcher_get_shm_seg_size (const void *shmaddr)
277277
seg_size = 0;
278278

279279
fd = open ("/proc/self/maps", O_RDONLY);
280-
assert (fd >= 0);
280+
if (fd < 0) {
281+
return 0;
282+
}
281283

282284
for (size_t read_offset = 0 ; ; ) {
283285
ssize_t nread = read(fd, buffer + read_offset, sizeof(buffer) - 1 - read_offset);

0 commit comments

Comments
 (0)