aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/kernel/sys_sparc.c18
-rw-r--r--arch/sparc64/kernel/sys_sparc.c18
2 files changed, 18 insertions, 18 deletions
diff --git a/arch/sparc/kernel/sys_sparc.c b/arch/sparc/kernel/sys_sparc.c
index 0cdfc9d294b4..a41c8a5c2007 100644
--- a/arch/sparc/kernel/sys_sparc.c
+++ b/arch/sparc/kernel/sys_sparc.c
@@ -465,21 +465,21 @@ sys_rt_sigaction(int sig,
465 465
466asmlinkage int sys_getdomainname(char __user *name, int len) 466asmlinkage int sys_getdomainname(char __user *name, int len)
467{ 467{
468 int nlen; 468 int nlen, err;
469 int err = -EFAULT;
470 469
470 if (len < 0 || len > __NEW_UTS_LEN)
471 return -EINVAL;
472
471 down_read(&uts_sem); 473 down_read(&uts_sem);
472 474
473 nlen = strlen(system_utsname.domainname) + 1; 475 nlen = strlen(system_utsname.domainname) + 1;
474
475 if (nlen < len) 476 if (nlen < len)
476 len = nlen; 477 len = nlen;
477 if (len > __NEW_UTS_LEN) 478
478 goto done; 479 err = -EFAULT;
479 if (copy_to_user(name, system_utsname.domainname, len)) 480 if (!copy_to_user(name, system_utsname.domainname, len))
480 goto done; 481 err = 0;
481 err = 0; 482
482done:
483 up_read(&uts_sem); 483 up_read(&uts_sem);
484 return err; 484 return err;
485} 485}
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c
index 51c056df528e..054d0abdb7ee 100644
--- a/arch/sparc64/kernel/sys_sparc.c
+++ b/arch/sparc64/kernel/sys_sparc.c
@@ -701,21 +701,21 @@ extern void check_pending(int signum);
701 701
702asmlinkage long sys_getdomainname(char __user *name, int len) 702asmlinkage long sys_getdomainname(char __user *name, int len)
703{ 703{
704 int nlen; 704 int nlen, err;
705 int err = -EFAULT; 705
706 if (len < 0 || len > __NEW_UTS_LEN)
707 return -EINVAL;
706 708
707 down_read(&uts_sem); 709 down_read(&uts_sem);
708 710
709 nlen = strlen(system_utsname.domainname) + 1; 711 nlen = strlen(system_utsname.domainname) + 1;
710
711 if (nlen < len) 712 if (nlen < len)
712 len = nlen; 713 len = nlen;
713 if (len > __NEW_UTS_LEN) 714
714 goto done; 715 err = -EFAULT;
715 if (copy_to_user(name, system_utsname.domainname, len)) 716 if (!copy_to_user(name, system_utsname.domainname, len))
716 goto done; 717 err = 0;
717 err = 0; 718
718done:
719 up_read(&uts_sem); 719 up_read(&uts_sem);
720 return err; 720 return err;
721} 721}