Skip to content

Commit a43e0fc

Browse files
committed
pstore: inode: Only d_invalidate() is needed
Unloading a modular pstore backend with records in pstorefs would trigger the dput() double-drop warning: WARNING: CPU: 0 PID: 2569 at fs/dcache.c:762 dput.part.0+0x3f3/0x410 Using the combo of d_drop()/dput() (as mentioned in Documentation/filesystems/vfs.rst) isn't the right approach here, and leads to the reference counting problem seen above. Use d_invalidate() and update the code to not bother checking for error codes that can never happen. Suggested-by: Alexander Viro <[email protected]> Fixes: 609e28b ("pstore: Remove filesystem records when backend is unregistered") Signed-off-by: Kees Cook <[email protected]> --- Cc: "Guilherme G. Piccoli" <[email protected]> Cc: Tony Luck <[email protected]> Cc: [email protected]
1 parent 41bccc9 commit a43e0fc

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fs/pstore/inode.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ int pstore_put_backend_records(struct pstore_info *psi)
307307
{
308308
struct pstore_private *pos, *tmp;
309309
struct dentry *root;
310-
int rc = 0;
311310

312311
root = psinfo_lock_root();
313312
if (!root)
@@ -317,19 +316,16 @@ int pstore_put_backend_records(struct pstore_info *psi)
317316
list_for_each_entry_safe(pos, tmp, &records_list, list) {
318317
if (pos->record->psi == psi) {
319318
list_del_init(&pos->list);
320-
rc = simple_unlink(d_inode(root), pos->dentry);
321-
if (WARN_ON(rc))
322-
break;
323-
d_drop(pos->dentry);
324-
dput(pos->dentry);
319+
d_invalidate(pos->dentry);
320+
simple_unlink(d_inode(root), pos->dentry);
325321
pos->dentry = NULL;
326322
}
327323
}
328324
}
329325

330326
inode_unlock(d_inode(root));
331327

332-
return rc;
328+
return 0;
333329
}
334330

335331
/*

0 commit comments

Comments
 (0)