summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2013-11-18 11:43:10 -0200
committerLucas De Marchi <lucas.demarchi@intel.com>2013-11-18 11:43:10 -0200
commitd3c16c7946e72b8b88cb41b95dc3d014d24f0e8a (patch)
tree2fbb66359cd27e36ccbed141e03052ef5858ab2e
parentcacbcc4215f65c3ae1a49e9b3c6858226f56e1a2 (diff)
downloadkmod-d3c16c7946e72b8b88cb41b95dc3d014d24f0e8a.tar.gz
file: use _cleanup_free_
-rw-r--r--libkmod/libkmod-file.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c
index 390f018..feb4a15 100644
--- a/libkmod/libkmod-file.c
+++ b/libkmod/libkmod-file.c
@@ -175,13 +175,12 @@ static int load_zlib(struct kmod_file *file)
{
int err = 0;
off_t did = 0, total = 0;
- unsigned char *p = NULL;
+ _cleanup_free_ unsigned char *p = NULL;
errno = 0;
file->gzf = gzdopen(file->fd, "rb");
- if (file->gzf == NULL) {
+ if (file->gzf == NULL)
return -errno;
- }
file->fd = -1; /* now owned by gzf due gzdopen() */
for (;;) {
@@ -215,9 +214,10 @@ static int load_zlib(struct kmod_file *file)
file->memory = p;
file->size = did;
+ p = NULL;
return 0;
+
error:
- free(p);
gzclose(file->gzf);
return err;
}