Browse Source

Bugfix: bigpic: Ensure devices that fail probe are closed properly

Luke Dashjr 12 years ago
parent
commit
1e1ff751e6
1 changed files with 4 additions and 2 deletions
  1. 4 2
      driver-bigpic.c

+ 4 - 2
driver-bigpic.c

@@ -48,6 +48,7 @@ static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, st
 	{
 		applog(LOG_ERR, "%s: Failed writing id request to %s",
 		       bigpic_drv.dname, devpath);
+		serial_close(fd);
 		return false;
 	}
 	len = serial_read(fd, buf, sizeof(buf));
@@ -71,11 +72,12 @@ static bool bigpic_detect_custom(const char *devpath, struct device_drv *api, st
 	{
 		applog(LOG_ERR, "%s: Failed writing reset request to %s",
 		       bigpic_drv.dname, devpath);
+		serial_close(fd);
 		return false;
 	}
 
-
-	while(len == 0)
+	int limit = 50;
+	while (len == 0 && --limit)
 	{
 		len = serial_read(fd, buf, sizeof(buf_state));
 		cgsleep_ms(100);