xfs: always init bma in xfs_bmapi_write
PATCH 1/1 xfs: always init bma in xfs_bmapi_write
From: Darrick J. Wong <[email protected]>
Always init the tp/ip fields of bma in xfs_bmapi_write so that the bmapi_finish at the bottom never trips over null transaction or inode pointers.
Coverity-id: 1443964
--- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +5 -5
@@ -4254,9 +4254,13 @@ xfs_bmapi_write(struct xfs_bmbt_irec *mval,/* output: map values */ int *nmap) /* i/o: mval size/count */ { + struct xfs_bmalloca bma = { + .tp = tp, + .ip = ip, + .total = total, + };struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp; -struct xfs_bmalloca bma = {NULL };/* args for xfs_bmap_alloc */ xfs_fileoff_t end;/* end of mapped file region */ bool eof = false;/* after the end of extents */ int error;/* error return */
@@ -4324,10 +4328,6 @@ xfs_bmapi_write( eof = true;if (!xfs_iext_peek_prev_extent (ifp, &bma.icur, &bma.prev)) bma.prev.br_startoff =NULLFILEOFF ; - bma.tp = tp; - bma.ip = ip; - bma.total = total; - bma.datatype =0 ; bma.minleft =xfs_bmapi_minleft (tp, ip, whichfork); n =0 ;
Quoted 17 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Always init the tp/ip fields of bma in
xfs_bmapi_writeso that thebmapi_finishat the bottom never trips over null transaction or inode pointers.Coverity-id: 1443964
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/xfs/libxfs/xfs_bmap.c +0
-0
fs/xfs/libxfs/xfs_bmap.c xfs_bmapi_write( · line 4261
Quoted 8 lines
fs/xfs/libxfs/xfs_bmap.c +5
-0@@ -4254,9 +4254,13 @@ xfs_bmapi_write(struct xfs_bmbt_irec *mval,/* output: map values */ int *nmap) /* i/o: mval size/count */ { + struct xfs_bmalloca bma = { + .tp = tp, + .ip = ip, + .total = total, + };
This should continue to zero-init the rest of the structure, right? If so, looks fine:
Quoted 17 lines
fs/xfs/libxfs/xfs_bmap.c +0
-5struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp; -struct xfs_bmalloca bma = {NULL };/* args for xfs_bmap_alloc */ xfs_fileoff_t end;/* end of mapped file region */ bool eof = false;/* after the end of extents */ int error;/* error return */ @@ -4324,10 +4328,6 @@ xfs_bmapi_write( eof = true;if (!xfs_iext_peek_prev_extent (ifp, &bma.icur, &bma.prev)) bma.prev.br_startoff =NULLFILEOFF ; - bma.tp = tp; - bma.ip = ip; - bma.total = total; - bma.datatype =0 ; bma.minleft =xfs_bmapi_minleft (tp, ip, whichfork); n =0 ;
Quoted 13 lines · Brian Foster
Quoted 12 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Always init the tp/ip fields of bma in
xfs_bmapi_writeso that thebmapi_finishat the bottom never trips over null transaction or inode pointers.Coverity-id: 1443964
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Quoted 15 lines
fs/xfs/libxfs/xfs_bmap.c xfs_bmapi_write( · line 4261
Quoted 13 lines
fs/xfs/libxfs/xfs_bmap.c +5
-0@@ -4254,9 +4254,13 @@ xfs_bmapi_write(struct xfs_bmbt_irec *mval,/* output: map values */ int *nmap) /* i/o: mval size/count */ { + struct xfs_bmalloca bma = { + .tp = tp, + .ip = ip, + .total = total, + };This should continue to zero-init the rest of the structure, right?
I hope so. If not, there's going to be a lot of corrupt in-core structs in the kernel... :)
Thanks for the review, btw.
--D
Quoted 21 lines
If so, looks fine:
Reviewed-by Brian Foster <[email protected]>Quoted 17 lines
fs/xfs/libxfs/xfs_bmap.c +0
-5struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp; -struct xfs_bmalloca bma = {NULL };/* args for xfs_bmap_alloc */ xfs_fileoff_t end;/* end of mapped file region */ bool eof = false;/* after the end of extents */ int error;/* error return */ @@ -4324,10 +4328,6 @@ xfs_bmapi_write( eof = true;if (!xfs_iext_peek_prev_extent (ifp, &bma.icur, &bma.prev)) bma.prev.br_startoff =NULLFILEOFF ; - bma.tp = tp; - bma.ip = ip; - bma.total = total; - bma.datatype =0 ; bma.minleft =xfs_bmapi_minleft (tp, ip, whichfork); n =0 ;