close lock_fd if flock failed (#2231)

old-commit-hash: 9983389ffe
commatwo_master
Dean Lee 5 years ago committed by GitHub
parent f127e4048e
commit 63c8162fd3
  1. 5
      selfdrive/common/params.cc

@ -305,7 +305,10 @@ int read_db_all(std::map<std::string, std::string> *params, bool persistent_para
if (lock_fd < 0) return -1; if (lock_fd < 0) return -1;
err = flock(lock_fd, LOCK_SH); err = flock(lock_fd, LOCK_SH);
if (err < 0) return err; if (err < 0) {
close(lock_fd);
return err;
}
std::string key_path = util::string_format("%s/d", params_path); std::string key_path = util::string_format("%s/d", params_path);
DIR *d = opendir(key_path.c_str()); DIR *d = opendir(key_path.c_str());

Loading…
Cancel
Save