Skip to content

Commit

Permalink
[PATCH] Really ignore kmem_cache_destroy return value
Browse files Browse the repository at this point in the history
* Rougly half of callers already do it by not checking return value
* Code in drivers/acpi/osl.c does the following to be sure:

	(void)kmem_cache_destroy(cache);

* Those who check it printk something, however, slab_error already printed
  the name of failed cache.
* XFS BUGs on failed kmem_cache_destroy which is not the decision
  low-level filesystem driver should make. Converted to ignore.

Signed-off-by: Alexey Dobriyan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Sep 27, 2006
1 parent f52720c commit 1a1d92c
Show file tree
Hide file tree
Showing 40 changed files with 53 additions and 130 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ acpi_status acpi_os_purge_cache(acpi_cache_t * cache)

acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
{
(void)kmem_cache_destroy(cache);
kmem_cache_destroy(cache);
return (AE_OK);
}

Expand Down
5 changes: 1 addition & 4 deletions drivers/infiniband/core/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2987,10 +2987,7 @@ static int __init ib_mad_init_module(void)
static void __exit ib_mad_cleanup_module(void)
{
ib_unregister_client(&mad_client);

if (kmem_cache_destroy(ib_mad_cache)) {
printk(KERN_DEBUG PFX "Failed to destroy ib_mad cache\n");
}
kmem_cache_destroy(ib_mad_cache);
}

module_init(ib_mad_init_module);
Expand Down
8 changes: 2 additions & 6 deletions drivers/usb/host/uhci-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,7 @@ static int __init uhci_hcd_init(void)
return 0;

init_failed:
if (kmem_cache_destroy(uhci_up_cachep))
warn("not all urb_privs were freed!");
kmem_cache_destroy(uhci_up_cachep);

up_failed:
debugfs_remove(uhci_debugfs_root);
Expand All @@ -930,10 +929,7 @@ static int __init uhci_hcd_init(void)
static void __exit uhci_hcd_cleanup(void)
{
pci_unregister_driver(&uhci_pci_driver);

if (kmem_cache_destroy(uhci_up_cachep))
warn("not all urb_privs were freed!");

kmem_cache_destroy(uhci_up_cachep);
debugfs_remove(uhci_debugfs_root);
kfree(errbuf);
}
Expand Down
3 changes: 1 addition & 2 deletions fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(adfs_inode_cachep))
printk(KERN_INFO "adfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(adfs_inode_cachep);
}

static struct super_operations adfs_sops = {
Expand Down
3 changes: 1 addition & 2 deletions fs/affs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(affs_inode_cachep))
printk(KERN_INFO "affs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(affs_inode_cachep);
}

static struct super_operations affs_sops = {
Expand Down
4 changes: 1 addition & 3 deletions fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ befs_init_inodecache(void)
static void
befs_destroy_inodecache(void)
{
if (kmem_cache_destroy(befs_inode_cachep))
printk(KERN_ERR "befs_destroy_inodecache: "
"not all structures were freed\n");
kmem_cache_destroy(befs_inode_cachep);
}

/*
Expand Down
3 changes: 1 addition & 2 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(bfs_inode_cachep))
printk(KERN_INFO "bfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(bfs_inode_cachep);
}

static struct super_operations bfs_sops = {
Expand Down
20 changes: 5 additions & 15 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,7 @@ cifs_init_inodecache(void)
static void
cifs_destroy_inodecache(void)
{
if (kmem_cache_destroy(cifs_inode_cachep))
printk(KERN_WARNING "cifs_inode_cache: error freeing\n");
kmem_cache_destroy(cifs_inode_cachep);
}

static int
Expand Down Expand Up @@ -778,13 +777,9 @@ static void
cifs_destroy_request_bufs(void)
{
mempool_destroy(cifs_req_poolp);
if (kmem_cache_destroy(cifs_req_cachep))
printk(KERN_WARNING
"cifs_destroy_request_cache: error not all structures were freed\n");
kmem_cache_destroy(cifs_req_cachep);
mempool_destroy(cifs_sm_req_poolp);
if (kmem_cache_destroy(cifs_sm_req_cachep))
printk(KERN_WARNING
"cifs_destroy_request_cache: cifs_small_rq free error\n");
kmem_cache_destroy(cifs_sm_req_cachep);
}

static int
Expand Down Expand Up @@ -819,13 +814,8 @@ static void
cifs_destroy_mids(void)
{
mempool_destroy(cifs_mid_poolp);
if (kmem_cache_destroy(cifs_mid_cachep))
printk(KERN_WARNING
"cifs_destroy_mids: error not all structures were freed\n");

if (kmem_cache_destroy(cifs_oplock_cachep))
printk(KERN_WARNING
"error not all oplock structures were freed\n");
kmem_cache_destroy(cifs_mid_cachep);
kmem_cache_destroy(cifs_oplock_cachep);
}

static int cifs_oplock_thread(void * dummyarg)
Expand Down
3 changes: 1 addition & 2 deletions fs/coda/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ int coda_init_inodecache(void)

void coda_destroy_inodecache(void)
{
if (kmem_cache_destroy(coda_inode_cachep))
printk(KERN_INFO "coda_inode_cache: not all structures were freed\n");
kmem_cache_destroy(coda_inode_cachep);
}

static int coda_remount(struct super_block *sb, int *flags, char *data)
Expand Down
3 changes: 1 addition & 2 deletions fs/efs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(efs_inode_cachep))
printk(KERN_INFO "efs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(efs_inode_cachep);
}

static void efs_put_super(struct super_block *s)
Expand Down
3 changes: 1 addition & 2 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(ext2_inode_cachep))
printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n");
kmem_cache_destroy(ext2_inode_cachep);
}

static void ext2_clear_inode(struct inode *inode)
Expand Down
3 changes: 1 addition & 2 deletions fs/ext3/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(ext3_inode_cachep))
printk(KERN_INFO "ext3_inode_cache: not all structures were freed\n");
kmem_cache_destroy(ext3_inode_cachep);
}

static void ext3_clear_inode(struct inode *inode)
Expand Down
3 changes: 1 addition & 2 deletions fs/fat/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ int __init fat_cache_init(void)

void fat_cache_destroy(void)
{
if (kmem_cache_destroy(fat_cache_cachep))
printk(KERN_INFO "fat_cache: not all structures were freed\n");
kmem_cache_destroy(fat_cache_cachep);
}

static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
Expand Down
3 changes: 1 addition & 2 deletions fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,7 @@ static int __init fat_init_inodecache(void)

static void __exit fat_destroy_inodecache(void)
{
if (kmem_cache_destroy(fat_inode_cachep))
printk(KERN_INFO "fat_inode_cache: not all structures were freed\n");
kmem_cache_destroy(fat_inode_cachep);
}

static int fat_remount(struct super_block *sb, int *flags, char *data)
Expand Down
3 changes: 1 addition & 2 deletions fs/hfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,7 @@ static int __init init_hfs_fs(void)
static void __exit exit_hfs_fs(void)
{
unregister_filesystem(&hfs_fs_type);
if (kmem_cache_destroy(hfs_inode_cachep))
printk(KERN_ERR "hfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(hfs_inode_cachep);
}

module_init(init_hfs_fs)
Expand Down
3 changes: 1 addition & 2 deletions fs/hfsplus/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ static int __init init_hfsplus_fs(void)
static void __exit exit_hfsplus_fs(void)
{
unregister_filesystem(&hfsplus_fs_type);
if (kmem_cache_destroy(hfsplus_inode_cachep))
printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n");
kmem_cache_destroy(hfsplus_inode_cachep);
}

module_init(init_hfsplus_fs)
Expand Down
3 changes: 1 addition & 2 deletions fs/hpfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(hpfs_inode_cachep))
printk(KERN_INFO "hpfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(hpfs_inode_cachep);
}

/*
Expand Down
4 changes: 1 addition & 3 deletions fs/isofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(isofs_inode_cachep))
printk(KERN_INFO "iso_inode_cache: not all structures were "
"freed\n");
kmem_cache_destroy(isofs_inode_cachep);
}

static int isofs_remount(struct super_block *sb, int *flags, char *data)
Expand Down
3 changes: 1 addition & 2 deletions fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(minix_inode_cachep))
printk(KERN_INFO "minix_inode_cache: not all structures were freed\n");
kmem_cache_destroy(minix_inode_cachep);
}

static struct super_operations minix_sops = {
Expand Down
3 changes: 1 addition & 2 deletions fs/ncpfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(ncp_inode_cachep))
printk(KERN_INFO "ncp_inode_cache: not all structures were freed\n");
kmem_cache_destroy(ncp_inode_cachep);
}

static int ncp_remount(struct super_block *sb, int *flags, char* data)
Expand Down
3 changes: 1 addition & 2 deletions fs/nfs/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,5 @@ int __init nfs_init_directcache(void)
*/
void nfs_destroy_directcache(void)
{
if (kmem_cache_destroy(nfs_direct_cachep))
printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n");
kmem_cache_destroy(nfs_direct_cachep);
}
3 changes: 1 addition & 2 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,8 +1134,7 @@ static int __init nfs_init_inodecache(void)

static void nfs_destroy_inodecache(void)
{
if (kmem_cache_destroy(nfs_inode_cachep))
printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(nfs_inode_cachep);
}

/*
Expand Down
3 changes: 1 addition & 2 deletions fs/nfs/pagelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ int __init nfs_init_nfspagecache(void)

void nfs_destroy_nfspagecache(void)
{
if (kmem_cache_destroy(nfs_page_cachep))
printk(KERN_INFO "nfs_page: not all structures were freed\n");
kmem_cache_destroy(nfs_page_cachep);
}

3 changes: 1 addition & 2 deletions fs/nfs/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,5 @@ int __init nfs_init_readpagecache(void)
void nfs_destroy_readpagecache(void)
{
mempool_destroy(nfs_rdata_mempool);
if (kmem_cache_destroy(nfs_rdata_cachep))
printk(KERN_INFO "nfs_read_data: not all structures were freed\n");
kmem_cache_destroy(nfs_rdata_cachep);
}
3 changes: 1 addition & 2 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,6 @@ void nfs_destroy_writepagecache(void)
{
mempool_destroy(nfs_commit_mempool);
mempool_destroy(nfs_wdata_mempool);
if (kmem_cache_destroy(nfs_wdata_cachep))
printk(KERN_INFO "nfs_write_data: not all structures were freed\n");
kmem_cache_destroy(nfs_wdata_cachep);
}

5 changes: 1 addition & 4 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,10 @@ alloc_init_file(struct inode *ino)
static void
nfsd4_free_slab(kmem_cache_t **slab)
{
int status;

if (*slab == NULL)
return;
status = kmem_cache_destroy(*slab);
kmem_cache_destroy(*slab);
*slab = NULL;
WARN_ON(status);
}

static void
Expand Down
28 changes: 5 additions & 23 deletions fs/ntfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3248,32 +3248,14 @@ static int __init init_ntfs_fs(void)

static void __exit exit_ntfs_fs(void)
{
int err = 0;

ntfs_debug("Unregistering NTFS driver.");

unregister_filesystem(&ntfs_fs_type);

if (kmem_cache_destroy(ntfs_big_inode_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
ntfs_big_inode_cache_name);
if (kmem_cache_destroy(ntfs_inode_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
ntfs_inode_cache_name);
if (kmem_cache_destroy(ntfs_name_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
ntfs_name_cache_name);
if (kmem_cache_destroy(ntfs_attr_ctx_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
ntfs_attr_ctx_cache_name);
if (kmem_cache_destroy(ntfs_index_ctx_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
ntfs_index_ctx_cache_name);
if (err)
printk(KERN_CRIT "NTFS: This causes memory to leak! There is "
"probably a BUG in the driver! Please report "
"you saw this message to "
"[email protected]\n");
kmem_cache_destroy(ntfs_big_inode_cache);
kmem_cache_destroy(ntfs_inode_cache);
kmem_cache_destroy(ntfs_name_cache);
kmem_cache_destroy(ntfs_attr_ctx_cache);
kmem_cache_destroy(ntfs_index_ctx_cache);
/* Unregister the ntfs sysctls. */
ntfs_sysctl(0);
}
Expand Down
4 changes: 1 addition & 3 deletions fs/ocfs2/dlm/dlmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,7 @@ static void __exit exit_dlmfs_fs(void)
flush_workqueue(user_dlm_worker);
destroy_workqueue(user_dlm_worker);

if (kmem_cache_destroy(dlmfs_inode_cache))
printk(KERN_INFO "dlmfs_inode_cache: not all structures "
"were freed\n");
kmem_cache_destroy(dlmfs_inode_cache);
}

MODULE_AUTHOR("Oracle");
Expand Down
4 changes: 1 addition & 3 deletions fs/qnx4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(qnx4_inode_cachep))
printk(KERN_INFO
"qnx4_inode_cache: not all structures were freed\n");
kmem_cache_destroy(qnx4_inode_cachep);
}

static int qnx4_get_sb(struct file_system_type *fs_type,
Expand Down
4 changes: 1 addition & 3 deletions fs/reiserfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(reiserfs_inode_cachep))
reiserfs_warning(NULL,
"reiserfs_inode_cache: not all structures were freed");
kmem_cache_destroy(reiserfs_inode_cachep);
}

/* we don't mark inodes dirty, we just log them */
Expand Down
3 changes: 1 addition & 2 deletions fs/romfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(romfs_inode_cachep))
printk(KERN_INFO "romfs_inode_cache: not all structures were freed\n");
kmem_cache_destroy(romfs_inode_cachep);
}

static int romfs_remount(struct super_block *sb, int *flags, char *data)
Expand Down
3 changes: 1 addition & 2 deletions fs/smbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ static int init_inodecache(void)

static void destroy_inodecache(void)
{
if (kmem_cache_destroy(smb_inode_cachep))
printk(KERN_INFO "smb_inode_cache: not all structures were freed\n");
kmem_cache_destroy(smb_inode_cachep);
}

static int smb_remount(struct super_block *sb, int *flags, char *data)
Expand Down
Loading

0 comments on commit 1a1d92c

Please sign in to comment.