diff options
| -rw-r--r-- | src/atcmd.c | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/src/atcmd.c b/src/atcmd.c index 6dee9ed..e153d39 100644 --- a/src/atcmd.c +++ b/src/atcmd.c @@ -1127,6 +1127,8 @@ int sms_device_close(int fd)  	if (lock_path) {  		unlink(lock_path); +		free(lock_path); +		lock_path = NULL;  	}  	return ret; @@ -1134,32 +1136,31 @@ int sms_device_close(int fd)  int sms_device_open(void)  { -	int fd; +	int fd = -1;  	int tmp;  	lock_path = device_lock(Global.core.device);  	if (!lock_path) { +		sms_device_close(fd);  		return -1;  	}  	fd = tty_open(Global.core.device, Global.core.baud_rate);  	if (fd < 0) { -		unlink(lock_path); +		sms_device_close(fd);  		return -1;  	}  	tmp = tty_set_read_timeout(fd, Global.core.read_timeout);  	if (tmp < 0) { -		close(fd); -		unlink(lock_path); +		sms_device_close(fd);  		return tmp;  	}  	if (Global.core.sms_init) {  		tmp = sms_atcmd_init(fd);  		if (tmp < 0) { -			close(fd); -			unlink(lock_path); +			sms_device_close(fd);  			return tmp;  		}  	} | 
