mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 14:41:27 +00:00
[XFS] avoid memory allocations in xfs_fs_vcmn_err
xfs_fs_vcmn_err can be called under a spinlock, but does a sleeping memory allocation to create buffer for it's internal sprintf. Fortunately it's the only caller of icmn_err, so we can merge the two and have one single static buffer and spinlock protecting it. While we're at it make sure we proper __attribute__ format annotations so that the compiler can detect mismatched format strings. Reported-by: Alexander Beregalov <a.beregalov@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Eric Sandeen <sandeen@sandeen.net> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
This commit is contained in:
parent
9f6c92b9cc
commit
efc557570d
4 changed files with 40 additions and 26 deletions
|
@ -153,21 +153,6 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud)
|
|||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
static void
|
||||
xfs_fs_vcmn_err(int level, xfs_mount_t *mp, char *fmt, va_list ap)
|
||||
{
|
||||
if (mp != NULL) {
|
||||
char *newfmt;
|
||||
int len = 16 + mp->m_fsname_len + strlen(fmt);
|
||||
|
||||
newfmt = kmem_alloc(len, KM_SLEEP);
|
||||
sprintf(newfmt, "Filesystem \"%s\": %s", mp->m_fsname, fmt);
|
||||
icmn_err(level, newfmt, ap);
|
||||
kmem_free(newfmt);
|
||||
} else {
|
||||
icmn_err(level, fmt, ap);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xfs_fs_cmn_err(int level, xfs_mount_t *mp, char *fmt, ...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue