aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2011-08-24 11:15:10 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2011-08-24 11:15:23 -0400
commitba465d830ed1703713251917f154688ec537580f (patch)
tree972fd00c8b2c72f320887c9910ba46f1d12314f7 /drivers/s390
parent27e7318c3e47e4fac71fcb472623434063ccc7a5 (diff)
[S390] drivers/s390/block/dasd_ioctl.c: add missing kfree
Data is only used to temporarily hold information to be copied to the user level, so it should be freed before leaving the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @exists@ local idexpression x; statement S,S1; expression E; identifier fl; expression *ptr != NULL; @@ x = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S <... when != x when != if (...) { <+...kfree(x)...+> } when any when != true x == NULL x->fl ...> ( if (x == NULL) S1 | if (...) { ... when != x when forall ( return \(0\|<+...x...+>\|ptr\); | * return ...; ) } ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/block/dasd_ioctl.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index eb4e034378c..f1a2016829f 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -249,6 +249,7 @@ static int dasd_ioctl_reset_profile(struct dasd_block *block)
249static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp) 249static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)
250{ 250{
251 struct dasd_profile_info_t *data; 251 struct dasd_profile_info_t *data;
252 int rc = 0;
252 253
253 data = kmalloc(sizeof(*data), GFP_KERNEL); 254 data = kmalloc(sizeof(*data), GFP_KERNEL);
254 if (!data) 255 if (!data)
@@ -279,11 +280,14 @@ static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp)
279 spin_unlock_bh(&block->profile.lock); 280 spin_unlock_bh(&block->profile.lock);
280 } else { 281 } else {
281 spin_unlock_bh(&block->profile.lock); 282 spin_unlock_bh(&block->profile.lock);
282 return -EIO; 283 rc = -EIO;
284 goto out;
283 } 285 }
284 if (copy_to_user(argp, data, sizeof(*data))) 286 if (copy_to_user(argp, data, sizeof(*data)))
285 return -EFAULT; 287 rc = -EFAULT;
286 return 0; 288out:
289 kfree(data);
290 return rc;
287} 291}
288#else 292#else
289static int dasd_ioctl_reset_profile(struct dasd_block *block) 293static int dasd_ioctl_reset_profile(struct dasd_block *block)