diff options
author | Jarek Poplawski <jarkao2@gmail.com> | 2009-09-24 23:10:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-25 16:43:48 -0400 |
commit | c0181d420cc1a506ca4418ce90e2ad89831eee2c (patch) | |
tree | 2c28009e8312427a2d934352c8c1c3363941d8af /net/ax25 | |
parent | a91eba5b9db4c09f53c8f23327915c7c75d3235f (diff) |
ax25: Fix ax25_cb refcounting in ax25_ctl_ioctl
Use ax25_cb_put after ax25_find_cb in ax25_ctl_ioctl.
Reported-by: Bernard Pidoux F6BVP <f6bvp@free.fr>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Reviewed-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ax25')
-rw-r--r-- | net/ax25/af_ax25.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index d6b1b054e294..fbcac76fdc0d 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -358,6 +358,7 @@ static int ax25_ctl_ioctl(const unsigned int cmd, void __user *arg) | |||
358 | ax25_dev *ax25_dev; | 358 | ax25_dev *ax25_dev; |
359 | ax25_cb *ax25; | 359 | ax25_cb *ax25; |
360 | unsigned int k; | 360 | unsigned int k; |
361 | int ret = 0; | ||
361 | 362 | ||
362 | if (copy_from_user(&ax25_ctl, arg, sizeof(ax25_ctl))) | 363 | if (copy_from_user(&ax25_ctl, arg, sizeof(ax25_ctl))) |
363 | return -EFAULT; | 364 | return -EFAULT; |
@@ -388,57 +389,63 @@ static int ax25_ctl_ioctl(const unsigned int cmd, void __user *arg) | |||
388 | case AX25_WINDOW: | 389 | case AX25_WINDOW: |
389 | if (ax25->modulus == AX25_MODULUS) { | 390 | if (ax25->modulus == AX25_MODULUS) { |
390 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7) | 391 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 7) |
391 | return -EINVAL; | 392 | goto einval_put; |
392 | } else { | 393 | } else { |
393 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63) | 394 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 63) |
394 | return -EINVAL; | 395 | goto einval_put; |
395 | } | 396 | } |
396 | ax25->window = ax25_ctl.arg; | 397 | ax25->window = ax25_ctl.arg; |
397 | break; | 398 | break; |
398 | 399 | ||
399 | case AX25_T1: | 400 | case AX25_T1: |
400 | if (ax25_ctl.arg < 1) | 401 | if (ax25_ctl.arg < 1) |
401 | return -EINVAL; | 402 | goto einval_put; |
402 | ax25->rtt = (ax25_ctl.arg * HZ) / 2; | 403 | ax25->rtt = (ax25_ctl.arg * HZ) / 2; |
403 | ax25->t1 = ax25_ctl.arg * HZ; | 404 | ax25->t1 = ax25_ctl.arg * HZ; |
404 | break; | 405 | break; |
405 | 406 | ||
406 | case AX25_T2: | 407 | case AX25_T2: |
407 | if (ax25_ctl.arg < 1) | 408 | if (ax25_ctl.arg < 1) |
408 | return -EINVAL; | 409 | goto einval_put; |
409 | ax25->t2 = ax25_ctl.arg * HZ; | 410 | ax25->t2 = ax25_ctl.arg * HZ; |
410 | break; | 411 | break; |
411 | 412 | ||
412 | case AX25_N2: | 413 | case AX25_N2: |
413 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31) | 414 | if (ax25_ctl.arg < 1 || ax25_ctl.arg > 31) |
414 | return -EINVAL; | 415 | goto einval_put; |
415 | ax25->n2count = 0; | 416 | ax25->n2count = 0; |
416 | ax25->n2 = ax25_ctl.arg; | 417 | ax25->n2 = ax25_ctl.arg; |
417 | break; | 418 | break; |
418 | 419 | ||
419 | case AX25_T3: | 420 | case AX25_T3: |
420 | if (ax25_ctl.arg < 0) | 421 | if (ax25_ctl.arg < 0) |
421 | return -EINVAL; | 422 | goto einval_put; |
422 | ax25->t3 = ax25_ctl.arg * HZ; | 423 | ax25->t3 = ax25_ctl.arg * HZ; |
423 | break; | 424 | break; |
424 | 425 | ||
425 | case AX25_IDLE: | 426 | case AX25_IDLE: |
426 | if (ax25_ctl.arg < 0) | 427 | if (ax25_ctl.arg < 0) |
427 | return -EINVAL; | 428 | goto einval_put; |
428 | ax25->idle = ax25_ctl.arg * 60 * HZ; | 429 | ax25->idle = ax25_ctl.arg * 60 * HZ; |
429 | break; | 430 | break; |
430 | 431 | ||
431 | case AX25_PACLEN: | 432 | case AX25_PACLEN: |
432 | if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535) | 433 | if (ax25_ctl.arg < 16 || ax25_ctl.arg > 65535) |
433 | return -EINVAL; | 434 | goto einval_put; |
434 | ax25->paclen = ax25_ctl.arg; | 435 | ax25->paclen = ax25_ctl.arg; |
435 | break; | 436 | break; |
436 | 437 | ||
437 | default: | 438 | default: |
438 | return -EINVAL; | 439 | goto einval_put; |
439 | } | 440 | } |
440 | 441 | ||
441 | return 0; | 442 | out_put: |
443 | ax25_cb_put(ax25); | ||
444 | return ret; | ||
445 | |||
446 | einval_put: | ||
447 | ret = -EINVAL; | ||
448 | goto out_put; | ||
442 | } | 449 | } |
443 | 450 | ||
444 | static void ax25_fillin_cb_from_dev(ax25_cb *ax25, ax25_dev *ax25_dev) | 451 | static void ax25_fillin_cb_from_dev(ax25_cb *ax25, ax25_dev *ax25_dev) |