]> git.ozlabs.org Git - petitboot/commitdiff
ui/common: Only close valid file descriptor
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Fri, 18 Dec 2015 02:51:00 +0000 (13:51 +1100)
committerSam Mendoza-Jonas <sam@mendozajonas.com>
Tue, 9 Feb 2016 02:39:34 +0000 (13:39 +1100)
Fixes Coverity defect #30466

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
ui/common/joystick.c

index 455ff19b9d759c2f536b0d8c73ff873f3622e19d..a3d6abd6acc37803809c75f6cbd887336bf54c0f 100644 (file)
@@ -98,8 +98,8 @@ struct pjs *pjs_init(void *ctx, int (*map)(const struct js_event *))
        return pjs;
 
 out_err:
        return pjs;
 
 out_err:
-       close(pjs->fd);
-       pjs->fd = 0;
+       if (pjs->fd >= 0)
+               close(pjs->fd);
        talloc_free(pjs);
        return NULL;
 }
        talloc_free(pjs);
        return NULL;
 }