diff options
author | Eric Wong <e@80x24.org> | 2015-08-17 06:00:30 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-17 07:38:57 +0000 |
commit | 7754b9ffc1b496170498f78fd2f05409dd0fb962 (patch) | |
tree | 294804418b165a52f720d77e4680f809025fb198 | |
parent | dc55a5b5bdd60850553ebf01adfe357d2a2a68b8 (diff) | |
download | cmogstored-7754b9ffc1b496170498f78fd2f05409dd0fb962.tar.gz |
The rest of cmogstored shall be updated to fail gracefully on OOM in due time. It may take a while, since not many systems encounter this, but we shall become more robust as time goes on.
-rw-r--r-- | dev.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -169,8 +169,17 @@ int mog_dev_mkusage(const struct mog_dev *dev, struct mog_svc *svc) if (!svc->mgmt_mfd) return 0; - usage_path = xasprintf("/dev%u/usage", (unsigned)dev->devid); - tmp_path = xasprintf("%s.%x", usage_path, (unsigned)getpid()); + if (asprintf(&usage_path, "/dev%u/usage", (unsigned)dev->devid) < 0) { + syslog(LOG_ERR, "error generating path: /dev%u/usage (%m)", + (unsigned)dev->devid); + return 0; + } + if (asprintf(&tmp_path, "%s.%x", usage_path, (unsigned)getpid()) < 0) { + syslog(LOG_ERR, "error generating path: /dev%u/usage.%u (%m)", + (unsigned)dev->devid, (unsigned)getpid()); + free(usage_path); + return 0; + } if (mog_unlink(svc, tmp_path) < 0 && errno != ENOENT) goto out; |