hsakmt: openclose.c: Fix Coverity reported warnings

Add check before close to prevent closing invalid file descriptors

Change-Id: Ie1d50e0d55159512a14a70c1e4be058218aae668


[ROCm/ROCR-Runtime commit: ff6e1b44bf]
This commit is contained in:
Shweta Khatri
2024-09-17 16:16:44 -04:00
committed by David Yat Sin
parent 94ee49bdbd
commit 848340186f
@@ -227,7 +227,8 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtOpenKFD(void)
return result;
topology_sysfs_failed:
kfd_version_failed:
close(fd);
if (fd >= 0)
close(fd);
open_failed:
pthread_mutex_unlock(&hsakmt_mutex);