[1/5] libxfs: don't barf in libxfs_bwrite on a null buffer ops name
diff mbox series

Message ID 158619915000.469742.14620929774691026014.stgit@magnolia
State Accepted
Headers show
Series
  • xfsprogs: rollup of various fixes for 5.6
Related show

Commit Message

Darrick J. Wong April 6, 2020, 6:52 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Don't crash if we failed to write a buffer that had no buffer verifier.
This should be rare in practice, but coverity found a valid bug.

Coverity-id: 1460462
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 libxfs/rdwr.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Allison Collins April 6, 2020, 10:06 p.m. UTC | #1
On 4/6/20 11:52 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't crash if we failed to write a buffer that had no buffer verifier.
> This should be rare in practice, but coverity found a valid bug.
> 
> Coverity-id: 1460462
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks ok:
Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> ---
>   libxfs/rdwr.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
> index 3c43a4d0..8a690269 100644
> --- a/libxfs/rdwr.c
> +++ b/libxfs/rdwr.c
> @@ -1028,7 +1028,7 @@ libxfs_bwrite(
>   	if (bp->b_error) {
>   		fprintf(stderr,
>   	_("%s: write failed on %s bno 0x%llx/0x%x, err=%d\n"),
> -			__func__, bp->b_ops->name,
> +			__func__, bp->b_ops ? bp->b_ops->name : "(unknown)",
>   			(long long)bp->b_bn, bp->b_bcount, -bp->b_error);
>   	} else {
>   		bp->b_flags |= LIBXFS_B_UPTODATE;
>
Christoph Hellwig April 9, 2020, 7:43 a.m. UTC | #2
On Mon, Apr 06, 2020 at 11:52:30AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Don't crash if we failed to write a buffer that had no buffer verifier.
> This should be rare in practice, but coverity found a valid bug.
> 
> Coverity-id: 1460462
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 3c43a4d0..8a690269 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1028,7 +1028,7 @@  libxfs_bwrite(
 	if (bp->b_error) {
 		fprintf(stderr,
 	_("%s: write failed on %s bno 0x%llx/0x%x, err=%d\n"),
-			__func__, bp->b_ops->name,
+			__func__, bp->b_ops ? bp->b_ops->name : "(unknown)",
 			(long long)bp->b_bn, bp->b_bcount, -bp->b_error);
 	} else {
 		bp->b_flags |= LIBXFS_B_UPTODATE;