usb: avoid closing -1. [rsc] --rw-rw-r-- M 779778 sape sys 3073 Apr 13 01:11 sys/src/cmd/usb/lib/device.c /n/sourcesdump/2006/0413/plan9/sys/src/cmd/usb/lib/device.c:37,44 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/usb/lib/device.c:37,45 sprint(name, "/dev/usb%d/new", ctlrno); if((d->ctl = open(name, ORDWR)) < 0){ Error0: - close(d->ctl); werrstr("open %s: %r", name); + if(d->ctl >= 0) + close(d->ctl); free(d); /* return nil; */ sysfatal("%r"); /n/sourcesdump/2006/0413/plan9/sys/src/cmd/usb/lib/device.c:58,64 - /n/sourcesdump/2006/0414/plan9/sys/src/cmd/usb/lib/device.c:59,66 strcpy(p, "setup"); if((d->setup = open(name, ORDWR)) < 0){ Error1: - close(d->setup); + if(d->setup >= 0) + close(d->setup); goto Error0; }