diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-05-13 18:20:33 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-06-30 02:04:08 -0400 |
commit | aa47cc1c3c7bd0df82b241aa2e3df36977b0c24b (patch) | |
tree | a7f3a39222ce83a697edb8fbe5f038d72a36fb19 /net/irda | |
parent | 7f2d17c67ae3a0954e35092564f1cf58726b2c44 (diff) |
irda: don't open-code memdup_user()
and no, GFP_ATOMIC does not make any sense there...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/irda')
-rw-r--r-- | net/irda/af_irda.c | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 8d77ad5cadaf..2e6990f8b80b 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -1901,16 +1901,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, optlen)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, optlen); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2032,16 +2026,10 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, optlen)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, optlen); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2317,16 +2305,10 @@ bed: goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, len)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, len); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } @@ -2381,16 +2363,10 @@ bed: goto out; } - ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); - if (ias_opt == NULL) { - err = -ENOMEM; - goto out; - } - /* Copy query to the driver. */ - if (copy_from_user(ias_opt, optval, len)) { - kfree(ias_opt); - err = -EFAULT; + ias_opt = memdup_user(optval, len); + if (IS_ERR(ias_opt)) { + err = PTR_ERR(ias_opt); goto out; } |