libblock/src/bdpart-register.c: Do not pass bad value to close()

Coverity CID 1467408

close() was called and fd can potentially be negative.

Closes #5113.
This commit is contained in:
Joel Sherrill
2024-08-09 08:54:45 -05:00
committed by Chris Johns
parent 447f767abc
commit 5e6d7dca8f

View File

@@ -208,8 +208,14 @@ rtems_status_code rtems_bdpart_unregister(
cleanup:
/*
* When we get here, logical_disk_name is guaranteed to be non-NULL
* but fd may be -1. Coverity flagged passing a bad value to close().
*/
free( logical_disk_name);
close( fd);
if (fd > 0) {
close( fd);
}
return esc;
}