xfs
[Top] [All Lists]

Re: [PATCH 3/3] xfs: optimize bio handling in the buffer writeback path

To: Eric Sandeen <sandeen@xxxxxxxxxxx>
Subject: Re: [PATCH 3/3] xfs: optimize bio handling in the buffer writeback path
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Tue, 31 May 2016 09:31:18 -0700
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <b8d49db2-131d-0735-c803-adec326f43bb@xxxxxxxxxxx>
References: <1458128681-10869-1-git-send-email-hch@xxxxxx> <1458128681-10869-4-git-send-email-hch@xxxxxx> <b8d49db2-131d-0735-c803-adec326f43bb@xxxxxxxxxxx>
User-agent: Mutt/1.5.24 (2015-08-30)
On Tue, May 31, 2016 at 10:35:01AM -0500, Eric Sandeen wrote:
> Coverity thinks this is problematic, calling it a
> "Free of address-of expression (BAD_FREE)"
> 
> CID 1362192
> 
> The issue is that if bio still == io_inline_bio, we are freeing
> memory which was not allocated.

No, we free the ioend into which the bio is embedded.  Take a look
at the allocation side in xfs_alloc_ioend:

        bio = bio_alloc_bioset(GFP_NOFS, BIO_MAX_PAGES, xfs_ioend_bioset);

        ioend = container_of(bio, struct xfs_ioend, io_inline_bio);


> Maybe this needs a:
> 
> if (bio != &ioend->io_inline_bio)
>       bio_put(bio);

That would leak every ioend used.

> or is there a better way?

We just need to shut up the checker..

<Prev in Thread] Current Thread [Next in Thread>