public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: check return of kmalloc in btrfs_control_ioctl
@ 2008-12-29  3:43 Shen Feng
  0 siblings, 0 replies; only message in thread
From: Shen Feng @ 2008-12-29  3:43 UTC (permalink / raw)
  To: linux-btrfs


The memory allocated by kmalloc should be checked before using it.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
---
 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 84c3b66..d0e8dce 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -590,6 +590,8 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	int len;
 
 	vol = kmalloc(sizeof(*vol), GFP_KERNEL);
+	if (!vol)
+		return -ENOMEM;
 	if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
 		ret = -EFAULT;
 		goto out;
-- 
1.6.0.6



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-29  3:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29  3:43 [PATCH] Btrfs: check return of kmalloc in btrfs_control_ioctl Shen Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox