Skip to content

Commit

Permalink
pstore: gracefully handle NULL pstore_info functions
Browse files Browse the repository at this point in the history
If a pstore backend doesn't want to support various portions of the
pstore interface, it can just leave those functions NULL instead of
creating no-op stubs.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Kees Cook authored and Tony Luck committed Nov 18, 2011
1 parent 3d6d8d2 commit 2174f6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion fs/pstore/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
{
struct pstore_private *p = dentry->d_inode->i_private;

p->psi->erase(p->type, p->id, p->psi);
if (p->psi->erase)
p->psi->erase(p->type, p->id, p->psi);

return simple_unlink(dir, dentry);
}
Expand Down
6 changes: 3 additions & 3 deletions fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ void pstore_get_records(int quiet)
return;

mutex_lock(&psi->read_mutex);
rc = psi->open(psi);
if (rc)
if (psi->open && psi->open(psi))
goto out;

while ((size = psi->read(&id, &type, &time, &buf, psi)) > 0) {
Expand All @@ -219,7 +218,8 @@ void pstore_get_records(int quiet)
if (rc && (rc != -EEXIST || !quiet))
failed++;
}
psi->close(psi);
if (psi->close)
psi->close(psi);
out:
mutex_unlock(&psi->read_mutex);

Expand Down

0 comments on commit 2174f6d

Please sign in to comment.