Resource leakage: 0 is a valid file descriptor
When testing if an fd is valid, the required construct is >= 0, not > 0. [Daniel: Fixed up the Linux MTRR case as well.] Signed-off-by: Martin Ettl <ettl.martin@gmx.de> Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
4151a13c80
commit
4df3e8c805
|
@ -72,7 +72,7 @@ BusInit (KdPointerInfo *pi)
|
|||
{
|
||||
for (i = 0; i < NUM_BUS_NAMES; i++)
|
||||
{
|
||||
if ((fd = open (BusNames[i], 0)) > 0)
|
||||
if ((fd = open (BusNames[i], 0)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
if (pi->path)
|
||||
|
@ -84,7 +84,7 @@ BusInit (KdPointerInfo *pi)
|
|||
}
|
||||
else
|
||||
{
|
||||
if ((fd = open(pi->path, 0)) > 0)
|
||||
if ((fd = open(pi->path, 0)) >= 0)
|
||||
{
|
||||
close(fd);
|
||||
return Success;
|
||||
|
@ -99,7 +99,7 @@ BusEnable (KdPointerInfo *pi)
|
|||
{
|
||||
int fd = open(pi->path, 0);
|
||||
|
||||
if (fd > 0)
|
||||
if (fd >= 0)
|
||||
{
|
||||
KdRegisterFd(fd, BusRead, pi);
|
||||
pi->driverPrivate = (void *)fd;
|
||||
|
|
|
@ -253,7 +253,7 @@ configureInputSection (void)
|
|||
int fd;
|
||||
#ifdef WSCONS_SUPPORT
|
||||
fd = open("/dev/wsmouse", 0);
|
||||
if (fd > 0) {
|
||||
if (fd >= 0) {
|
||||
DFLT_MOUSE_DEV = "/dev/wsmouse";
|
||||
DFLT_MOUSE_PROTO = "wsmouse";
|
||||
close(fd);
|
||||
|
|
|
@ -336,7 +336,7 @@ mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
|
|||
{
|
||||
struct mtrr_wc_region *p, *prev;
|
||||
|
||||
if (mtrr_fd > 0) {
|
||||
if (mtrr_fd >= 0) {
|
||||
p = wcr;
|
||||
while (p) {
|
||||
if (p->added)
|
||||
|
|
Loading…
Reference in New Issue
Block a user