Fixes for Coverity CIDs 702013,702014,702015,702016,702017.
Satisfying Coverity for case of resource leak in case open() returns file descriptor equal to 0.
This commit is contained in:
@@ -29,7 +29,7 @@ void create_log()
|
|||||||
|
|
||||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||||
int fd = open(gLogFilePath, flags, 0666);
|
int fd = open(gLogFilePath, flags, 0666);
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||||
@@ -108,7 +108,7 @@ void SiS7018_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
|
|
||||||
mutex_lock(&gLogLock);
|
mutex_lock(&gLogLock);
|
||||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
write(fd, buffer, strlen(buffer));
|
write(fd, buffer, strlen(buffer));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void create_log()
|
|||||||
|
|
||||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||||
int fd = open(gLogFilePath, flags, 0666);
|
int fd = open(gLogFilePath, flags, 0666);
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||||
@@ -122,7 +122,7 @@ void SiS19X_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
|
|
||||||
mutex_lock(&gLogLock);
|
mutex_lock(&gLogLock);
|
||||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
write(fd, buffer, strlen(buffer));
|
write(fd, buffer, strlen(buffer));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void create_log()
|
|||||||
|
|
||||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||||
int fd = open(gLogFilePath, flags, 0666);
|
int fd = open(gLogFilePath, flags, 0666);
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||||
@@ -117,7 +117,7 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
|
|
||||||
mutex_lock(&gLogLock);
|
mutex_lock(&gLogLock);
|
||||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
write(fd, buffer, strlen(buffer));
|
write(fd, buffer, strlen(buffer));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void create_log()
|
|||||||
|
|
||||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||||
int fd = open(gLogFilePath, flags, 0666);
|
int fd = open(gLogFilePath, flags, 0666);
|
||||||
if (fd > 0)
|
if (fd >= 0)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||||
@@ -124,7 +124,7 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
|
|
||||||
mutex_lock(&gLogLock);
|
mutex_lock(&gLogLock);
|
||||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||||
if (fd > 0) {
|
if (fd >= 0) {
|
||||||
write(fd, buffer, strlen(buffer));
|
write(fd, buffer, strlen(buffer));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user