Skip to content

Commit c02be23

Browse files
committed
Merge tag 'xfs-4.16-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fixes from Darrick Wong: - fix some compiler warnings - fix block reservations for transactions created during log recovery - fix resource leaks when respecifying mount options * tag 'xfs-4.16-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix potential memory leak in mount option parsing xfs: reserve blocks for refcount / rmap log item recovery xfs: use memset to initialize xfs_scrub_agfl_info
2 parents b1aad68 + 5b4c845 commit c02be23

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎fs/xfs/scrub/agheader.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ int
767767
xfs_scrub_agfl(
768768
struct xfs_scrub_context *sc)
769769
{
770-
struct xfs_scrub_agfl_info sai = { 0 };
770+
struct xfs_scrub_agfl_info sai;
771771
struct xfs_agf *agf;
772772
xfs_agnumber_t agno;
773773
unsigned int agflcount;
@@ -795,6 +795,7 @@ xfs_scrub_agfl(
795795
xfs_scrub_block_set_corrupt(sc, sc->sa.agf_bp);
796796
goto out;
797797
}
798+
memset(&sai, 0, sizeof(sai));
798799
sai.sz_entries = agflcount;
799800
sai.entries = kmem_zalloc(sizeof(xfs_agblock_t) * agflcount, KM_NOFS);
800801
if (!sai.entries) {

‎fs/xfs/xfs_refcount_item.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "xfs_log_format.h"
2424
#include "xfs_trans_resv.h"
2525
#include "xfs_bit.h"
26+
#include "xfs_shared.h"
2627
#include "xfs_mount.h"
2728
#include "xfs_defer.h"
2829
#include "xfs_trans.h"
@@ -456,10 +457,12 @@ xfs_cui_recover(
456457
* transaction. Normally, any work that needs to be deferred
457458
* gets attached to the same defer_ops that scheduled the
458459
* refcount update. However, we're in log recovery here, so we
459-
* we create our own defer_ops and use that to finish up any
460-
* work that doesn't fit.
460+
* we use the passed in defer_ops and to finish up any work that
461+
* doesn't fit. We need to reserve enough blocks to handle a
462+
* full btree split on either end of the refcount range.
461463
*/
462-
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
464+
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
465+
mp->m_refc_maxlevels * 2, 0, XFS_TRANS_RESERVE, &tp);
463466
if (error)
464467
return error;
465468
cudp = xfs_trans_get_cud(tp, cuip);

‎fs/xfs/xfs_rmap_item.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "xfs_log_format.h"
2424
#include "xfs_trans_resv.h"
2525
#include "xfs_bit.h"
26+
#include "xfs_shared.h"
2627
#include "xfs_mount.h"
2728
#include "xfs_defer.h"
2829
#include "xfs_trans.h"
@@ -470,7 +471,8 @@ xfs_rui_recover(
470471
}
471472
}
472473

473-
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
474+
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
475+
mp->m_rmap_maxlevels, 0, XFS_TRANS_RESERVE, &tp);
474476
if (error)
475477
return error;
476478
rudp = xfs_trans_get_rud(tp, ruip);

‎fs/xfs/xfs_super.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ xfs_parseargs(
250250
return -EINVAL;
251251
break;
252252
case Opt_logdev:
253+
kfree(mp->m_logname);
253254
mp->m_logname = match_strdup(args);
254255
if (!mp->m_logname)
255256
return -ENOMEM;
@@ -258,6 +259,7 @@ xfs_parseargs(
258259
xfs_warn(mp, "%s option not allowed on this system", p);
259260
return -EINVAL;
260261
case Opt_rtdev:
262+
kfree(mp->m_rtname);
261263
mp->m_rtname = match_strdup(args);
262264
if (!mp->m_rtname)
263265
return -ENOMEM;

0 commit comments

Comments
 (0)