Message ID | 20161024024335.6770-1-quwenruo@cn.fujitsu.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
At 10/24/2016 10:43 AM, Qu Wenruo wrote: > Ebs and pointers are allocated, but if any of the allocation failed, we > should free the allocated memory. > > Reported-by: David Sterba <dsterba@suse.cz> > Resolves-Coverity-CID: 1296749 Sorry, wrong CID here, Correct ones are: Resolves-Coverity-CID: 1374101 Resolves-Coverity-CID: 1374100 > Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> > --- > volumes.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/volumes.c b/volumes.c > index a7abd92..f687b0d 100644 > --- a/volumes.c > +++ b/volumes.c > @@ -2120,8 +2120,11 @@ int write_raid56_with_parity(struct btrfs_fs_info *info, > > ebs = malloc(sizeof(*ebs) * multi->num_stripes); > pointers = malloc(sizeof(*pointers) * multi->num_stripes); > - if (!ebs || !pointers) > + if (!ebs || !pointers) { > + free(ebs); > + free(pointers); > return -ENOMEM; > + } > > if (stripe_len > alloc_size) > alloc_size = stripe_len; > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Mon, Oct 24, 2016 at 10:43:32AM +0800, Qu Wenruo wrote: > Ebs and pointers are allocated, but if any of the allocation failed, we > should free the allocated memory. > > Reported-by: David Sterba <dsterba@suse.cz> > Resolves-Coverity-CID: 1296749 > Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> 1-4 applied, thanks. Please don't put my reported-by there. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/volumes.c b/volumes.c index a7abd92..f687b0d 100644 --- a/volumes.c +++ b/volumes.c @@ -2120,8 +2120,11 @@ int write_raid56_with_parity(struct btrfs_fs_info *info, ebs = malloc(sizeof(*ebs) * multi->num_stripes); pointers = malloc(sizeof(*pointers) * multi->num_stripes); - if (!ebs || !pointers) + if (!ebs || !pointers) { + free(ebs); + free(pointers); return -ENOMEM; + } if (stripe_len > alloc_size) alloc_size = stripe_len;
Ebs and pointers are allocated, but if any of the allocation failed, we should free the allocated memory. Reported-by: David Sterba <dsterba@suse.cz> Resolves-Coverity-CID: 1296749 Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> --- volumes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)