diff options
author | Patrick McHardy <kaber@trash.net> | 2007-06-13 15:06:43 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 01:14:59 -0400 |
commit | 2ae0bf69b716d07126f0a9c17fcc2d76da172cb6 (patch) | |
tree | a7cbfcbfa3e5fe95ae77e1fc0a73745f657edf7a /net | |
parent | e89fe42cd03c8fd3686df82d8390a235717a66de (diff) |
[VLAN]: Return proper error codes in register_vlan_device
The returned device is unused, return proper error codes instead and avoid
having the ioctl handler guess the error.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/8021q/vlan.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index e68b503f1012..5801993182b4 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -493,14 +493,14 @@ out_free_group: | |||
493 | } | 493 | } |
494 | 494 | ||
495 | /* Attach a VLAN device to a mac address (ie Ethernet Card). | 495 | /* Attach a VLAN device to a mac address (ie Ethernet Card). |
496 | * Returns the device that was created, or NULL if there was | 496 | * Returns 0 if the device was created or a negative error code otherwise. |
497 | * an error of some kind. | ||
498 | */ | 497 | */ |
499 | static struct net_device *register_vlan_device(struct net_device *real_dev, | 498 | static int register_vlan_device(struct net_device *real_dev, |
500 | unsigned short VLAN_ID) | 499 | unsigned short VLAN_ID) |
501 | { | 500 | { |
502 | struct net_device *new_dev; | 501 | struct net_device *new_dev; |
503 | char name[IFNAMSIZ]; | 502 | char name[IFNAMSIZ]; |
503 | int err; | ||
504 | 504 | ||
505 | #ifdef VLAN_DEBUG | 505 | #ifdef VLAN_DEBUG |
506 | printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n", | 506 | printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n", |
@@ -508,10 +508,11 @@ static struct net_device *register_vlan_device(struct net_device *real_dev, | |||
508 | #endif | 508 | #endif |
509 | 509 | ||
510 | if (VLAN_ID >= VLAN_VID_MASK) | 510 | if (VLAN_ID >= VLAN_VID_MASK) |
511 | goto out_ret_null; | 511 | return -ERANGE; |
512 | 512 | ||
513 | if (vlan_check_real_dev(real_dev, VLAN_ID) < 0) | 513 | err = vlan_check_real_dev(real_dev, VLAN_ID); |
514 | goto out_ret_null; | 514 | if (err < 0) |
515 | return err; | ||
515 | 516 | ||
516 | /* Gotta set up the fields for the device. */ | 517 | /* Gotta set up the fields for the device. */ |
517 | #ifdef VLAN_DEBUG | 518 | #ifdef VLAN_DEBUG |
@@ -547,7 +548,7 @@ static struct net_device *register_vlan_device(struct net_device *real_dev, | |||
547 | vlan_setup); | 548 | vlan_setup); |
548 | 549 | ||
549 | if (new_dev == NULL) | 550 | if (new_dev == NULL) |
550 | goto out_ret_null; | 551 | return -ENOBUFS; |
551 | 552 | ||
552 | /* need 4 bytes for extra VLAN header info, | 553 | /* need 4 bytes for extra VLAN header info, |
553 | * hope the underlying device can handle it. | 554 | * hope the underlying device can handle it. |
@@ -566,7 +567,8 @@ static struct net_device *register_vlan_device(struct net_device *real_dev, | |||
566 | VLAN_DEV_INFO(new_dev)->dent = NULL; | 567 | VLAN_DEV_INFO(new_dev)->dent = NULL; |
567 | VLAN_DEV_INFO(new_dev)->flags = 1; | 568 | VLAN_DEV_INFO(new_dev)->flags = 1; |
568 | 569 | ||
569 | if (register_vlan_dev(new_dev) < 0) | 570 | err = register_vlan_dev(new_dev); |
571 | if (err < 0) | ||
570 | goto out_free_newdev; | 572 | goto out_free_newdev; |
571 | 573 | ||
572 | /* Account for reference in struct vlan_dev_info */ | 574 | /* Account for reference in struct vlan_dev_info */ |
@@ -574,13 +576,11 @@ static struct net_device *register_vlan_device(struct net_device *real_dev, | |||
574 | #ifdef VLAN_DEBUG | 576 | #ifdef VLAN_DEBUG |
575 | printk(VLAN_DBG "Allocated new device successfully, returning.\n"); | 577 | printk(VLAN_DBG "Allocated new device successfully, returning.\n"); |
576 | #endif | 578 | #endif |
577 | return new_dev; | 579 | return 0; |
578 | 580 | ||
579 | out_free_newdev: | 581 | out_free_newdev: |
580 | free_netdev(new_dev); | 582 | free_netdev(new_dev); |
581 | 583 | return err; | |
582 | out_ret_null: | ||
583 | return NULL; | ||
584 | } | 584 | } |
585 | 585 | ||
586 | static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr) | 586 | static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr) |
@@ -753,11 +753,7 @@ static int vlan_ioctl_handler(void __user *arg) | |||
753 | err = -EPERM; | 753 | err = -EPERM; |
754 | if (!capable(CAP_NET_ADMIN)) | 754 | if (!capable(CAP_NET_ADMIN)) |
755 | break; | 755 | break; |
756 | if (register_vlan_device(dev, args.u.VID)) { | 756 | err = register_vlan_device(dev, args.u.VID); |
757 | err = 0; | ||
758 | } else { | ||
759 | err = -EINVAL; | ||
760 | } | ||
761 | break; | 757 | break; |
762 | 758 | ||
763 | case DEL_VLAN_CMD: | 759 | case DEL_VLAN_CMD: |