From 16c807f16a14a106fe4af68a42cbb90146873fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9C=88=E5=85=B3?= Date: Thu, 21 Nov 2024 15:03:17 +0800 Subject: [PATCH 1/2] AI review alarms modify. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李月关 --- libdmabufheap/src/dmabuf_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libdmabufheap/src/dmabuf_alloc.c b/libdmabufheap/src/dmabuf_alloc.c index 6d759f9..963fc7e 100644 --- a/libdmabufheap/src/dmabuf_alloc.c +++ b/libdmabufheap/src/dmabuf_alloc.c @@ -74,6 +74,10 @@ int DmabufHeapOpen(const char *heapName) return -EINVAL; } int fd = open(heapPath, O_RDONLY | O_CLOEXEC); + if (fd < 0) { + HILOG_ERROR(LOG_CORE, "file open faild, heapName = %s, errno = %d.", heapName, errno); + return -errno; + } long newFd = fd; memtrace((void *)newFd, HEAP_NAME_MAX_LEN, "DmabufHeap", true); return fd; @@ -119,6 +123,10 @@ int DmabufHeapBufferFree(DmabufHeapBuffer *buffer) return -EINVAL; } memtrace((void *)buffer, buffer->size, "DmabufHeap", false); + if (buffer->fd < 0) { + HILOG_ERROR(LOG_CORE, "%{public}s: Invalid file descriptor!", __func__); + return -EINVAL; + } return close(buffer->fd); } -- Gitee From c301d38e4f9067e6cf06fc55192efec82fa86b3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=9C=88=E5=85=B3?= Date: Thu, 21 Nov 2024 08:47:37 +0000 Subject: [PATCH 2/2] update libdmabufheap/src/dmabuf_alloc.c. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李月关 --- libdmabufheap/src/dmabuf_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdmabufheap/src/dmabuf_alloc.c b/libdmabufheap/src/dmabuf_alloc.c index 963fc7e..d8c9c56 100644 --- a/libdmabufheap/src/dmabuf_alloc.c +++ b/libdmabufheap/src/dmabuf_alloc.c @@ -76,7 +76,7 @@ int DmabufHeapOpen(const char *heapName) int fd = open(heapPath, O_RDONLY | O_CLOEXEC); if (fd < 0) { HILOG_ERROR(LOG_CORE, "file open faild, heapName = %s, errno = %d.", heapName, errno); - return -errno; + return fd; } long newFd = fd; memtrace((void *)newFd, HEAP_NAME_MAX_LEN, "DmabufHeap", true); -- Gitee