aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/selinuxfs.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2005-10-30 17:59:21 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:11 -0500
commit89d155ef62e5e0c10e4b37aaa5056f0beafe10e6 (patch)
tree7de1f357efd619000970526ca2688f79b9022417 /security/selinux/selinuxfs.c
parent0d078f6f96809c95c69b99d6605a502b0ac63d3d (diff)
[PATCH] SELinux: convert to kzalloc
This patch converts SELinux code from kmalloc/memset to the new kazalloc unction. On i386, this results in a text saving of over 1K. Before: text data bss dec hex filename 86319 4642 15236 106197 19ed5 security/selinux/built-in.o After: text data bss dec hex filename 85278 4642 15236 105156 19ac4 security/selinux/built-in.o Signed-off-by: James Morris <jmorris@namei.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r--security/selinux/selinuxfs.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index a45cc971e735..5f8427627211 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -424,15 +424,13 @@ static ssize_t sel_write_access(struct file * file, char *buf, size_t size)
424 return length; 424 return length;
425 425
426 length = -ENOMEM; 426 length = -ENOMEM;
427 scon = kmalloc(size+1, GFP_KERNEL); 427 scon = kzalloc(size+1, GFP_KERNEL);
428 if (!scon) 428 if (!scon)
429 return length; 429 return length;
430 memset(scon, 0, size+1);
431 430
432 tcon = kmalloc(size+1, GFP_KERNEL); 431 tcon = kzalloc(size+1, GFP_KERNEL);
433 if (!tcon) 432 if (!tcon)
434 goto out; 433 goto out;
435 memset(tcon, 0, size+1);
436 434
437 length = -EINVAL; 435 length = -EINVAL;
438 if (sscanf(buf, "%s %s %hu %x", scon, tcon, &tclass, &req) != 4) 436 if (sscanf(buf, "%s %s %hu %x", scon, tcon, &tclass, &req) != 4)
@@ -475,15 +473,13 @@ static ssize_t sel_write_create(struct file * file, char *buf, size_t size)
475 return length; 473 return length;
476 474
477 length = -ENOMEM; 475 length = -ENOMEM;
478 scon = kmalloc(size+1, GFP_KERNEL); 476 scon = kzalloc(size+1, GFP_KERNEL);
479 if (!scon) 477 if (!scon)
480 return length; 478 return length;
481 memset(scon, 0, size+1);
482 479
483 tcon = kmalloc(size+1, GFP_KERNEL); 480 tcon = kzalloc(size+1, GFP_KERNEL);
484 if (!tcon) 481 if (!tcon)
485 goto out; 482 goto out;
486 memset(tcon, 0, size+1);
487 483
488 length = -EINVAL; 484 length = -EINVAL;
489 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 485 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
@@ -536,15 +532,13 @@ static ssize_t sel_write_relabel(struct file * file, char *buf, size_t size)
536 return length; 532 return length;
537 533
538 length = -ENOMEM; 534 length = -ENOMEM;
539 scon = kmalloc(size+1, GFP_KERNEL); 535 scon = kzalloc(size+1, GFP_KERNEL);
540 if (!scon) 536 if (!scon)
541 return length; 537 return length;
542 memset(scon, 0, size+1);
543 538
544 tcon = kmalloc(size+1, GFP_KERNEL); 539 tcon = kzalloc(size+1, GFP_KERNEL);
545 if (!tcon) 540 if (!tcon)
546 goto out; 541 goto out;
547 memset(tcon, 0, size+1);
548 542
549 length = -EINVAL; 543 length = -EINVAL;
550 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 544 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)
@@ -595,15 +589,13 @@ static ssize_t sel_write_user(struct file * file, char *buf, size_t size)
595 return length; 589 return length;
596 590
597 length = -ENOMEM; 591 length = -ENOMEM;
598 con = kmalloc(size+1, GFP_KERNEL); 592 con = kzalloc(size+1, GFP_KERNEL);
599 if (!con) 593 if (!con)
600 return length; 594 return length;
601 memset(con, 0, size+1);
602 595
603 user = kmalloc(size+1, GFP_KERNEL); 596 user = kzalloc(size+1, GFP_KERNEL);
604 if (!user) 597 if (!user)
605 goto out; 598 goto out;
606 memset(user, 0, size+1);
607 599
608 length = -EINVAL; 600 length = -EINVAL;
609 if (sscanf(buf, "%s %s", con, user) != 2) 601 if (sscanf(buf, "%s %s", con, user) != 2)
@@ -658,15 +650,13 @@ static ssize_t sel_write_member(struct file * file, char *buf, size_t size)
658 return length; 650 return length;
659 651
660 length = -ENOMEM; 652 length = -ENOMEM;
661 scon = kmalloc(size+1, GFP_KERNEL); 653 scon = kzalloc(size+1, GFP_KERNEL);
662 if (!scon) 654 if (!scon)
663 return length; 655 return length;
664 memset(scon, 0, size+1);
665 656
666 tcon = kmalloc(size+1, GFP_KERNEL); 657 tcon = kzalloc(size+1, GFP_KERNEL);
667 if (!tcon) 658 if (!tcon)
668 goto out; 659 goto out;
669 memset(tcon, 0, size+1);
670 660
671 length = -EINVAL; 661 length = -EINVAL;
672 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) 662 if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3)