diff options
author | Mark Johnston <markj@FreeBSD.org> | 2018-02-16 15:41:03 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2018-02-16 15:41:03 +0000 |
commit | 16759360d44b416be38238fb2d5a51bb0934bbf6 (patch) | |
tree | e767c12a340c04dc1f4e9c623612687b414de4fc /stand/libsa | |
parent | 3f060b60b12a5ad3fe7d33f69957ea4a69e9e6e9 (diff) | |
download | src-16759360d44b416be38238fb2d5a51bb0934bbf6.tar.gz src-16759360d44b416be38238fb2d5a51bb0934bbf6.zip |
Fix a memory leak introduced in r328426.
ffs_sbget() may return a superblock buffer even if it fails, so the
caller must be prepared to free it in this case. Moreover, when tasting
alternate superblock locations in a loop, ffs_sbget()'s readfunc
callback must free the previously allocated buffer.
Reported and tested by: pho
Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D14390
Notes
Notes:
svn path=/head/; revision=329375
Diffstat (limited to 'stand/libsa')
-rw-r--r-- | stand/libsa/ufs.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/stand/libsa/ufs.c b/stand/libsa/ufs.c index 1f0b7d3591f6..786cbb80f1d5 100644 --- a/stand/libsa/ufs.c +++ b/stand/libsa/ufs.c @@ -687,6 +687,7 @@ ufs_use_sa_read(void *devfd, off_t loc, void **bufp, int size) int error; f = (struct open_file *)devfd; + free(*bufp); if ((*bufp = malloc(size)) == NULL) return (ENOSPC); error = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, loc / DEV_BSIZE, |