diff options
author | Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> | 2011-04-27 10:43:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-28 16:43:49 -0400 |
commit | 89b4208e2861bc7dc325840b44bae302a4e30add (patch) | |
tree | d6f708da6068510ab8ac948da3d3b5ec39c6a0c9 | |
parent | 63c3a66fe6c827a731dcbdee181158b295626f83 (diff) |
qlcnic: fix memory leak in qlcnic_blink_led.
o Memory allocated in ETHTOOL_ACTIVE mode, is not getting freed. So,
in ETHTOOL_ID_INACTIVE mode, return after freeing allocated memory.
o Using set bit instead of blink_down field, as it is also required
in internal Loopback test and etc.
Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/qlcnic/qlcnic.h | 2 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_ethtool.c | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index fa5b15c474b0..f7acb807a03d 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h | |||
@@ -884,6 +884,7 @@ struct qlcnic_ipaddr { | |||
884 | #define __QLCNIC_RESETTING 2 | 884 | #define __QLCNIC_RESETTING 2 |
885 | #define __QLCNIC_START_FW 4 | 885 | #define __QLCNIC_START_FW 4 |
886 | #define __QLCNIC_AER 5 | 886 | #define __QLCNIC_AER 5 |
887 | #define __QLCNIC_DIAG_RES_ALLOC 6 | ||
887 | 888 | ||
888 | #define QLCNIC_INTERRUPT_TEST 1 | 889 | #define QLCNIC_INTERRUPT_TEST 1 |
889 | #define QLCNIC_LOOPBACK_TEST 2 | 890 | #define QLCNIC_LOOPBACK_TEST 2 |
@@ -913,7 +914,6 @@ struct qlcnic_adapter { | |||
913 | struct net_device *netdev; | 914 | struct net_device *netdev; |
914 | struct pci_dev *pdev; | 915 | struct pci_dev *pdev; |
915 | 916 | ||
916 | bool blink_was_down; | ||
917 | unsigned long state; | 917 | unsigned long state; |
918 | u32 flags; | 918 | u32 flags; |
919 | 919 | ||
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c index 615a5ab88456..de65847f3559 100644 --- a/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/qlcnic/qlcnic_ethtool.c | |||
@@ -772,7 +772,6 @@ static int qlcnic_set_led(struct net_device *dev, | |||
772 | 772 | ||
773 | switch (state) { | 773 | switch (state) { |
774 | case ETHTOOL_ID_ACTIVE: | 774 | case ETHTOOL_ID_ACTIVE: |
775 | adapter->blink_was_down = false; | ||
776 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | 775 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { |
777 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | 776 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) |
778 | return -EIO; | 777 | return -EIO; |
@@ -781,7 +780,7 @@ static int qlcnic_set_led(struct net_device *dev, | |||
781 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 780 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
782 | return -EIO; | 781 | return -EIO; |
783 | } | 782 | } |
784 | adapter->blink_was_down = true; | 783 | set_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state); |
785 | } | 784 | } |
786 | 785 | ||
787 | if (adapter->nic_ops->config_led(adapter, 1, 0xf) == 0) | 786 | if (adapter->nic_ops->config_led(adapter, 1, 0xf) == 0) |
@@ -792,18 +791,17 @@ static int qlcnic_set_led(struct net_device *dev, | |||
792 | break; | 791 | break; |
793 | 792 | ||
794 | case ETHTOOL_ID_INACTIVE: | 793 | case ETHTOOL_ID_INACTIVE: |
795 | if (adapter->nic_ops->config_led(adapter, 0, 0xf) == 0) | 794 | if (adapter->nic_ops->config_led(adapter, 0, 0xf)) |
796 | return 0; | 795 | dev_err(&adapter->pdev->dev, |
796 | "Failed to reset LED blink state.\n"); | ||
797 | 797 | ||
798 | dev_err(&adapter->pdev->dev, | ||
799 | "Failed to reset LED blink state.\n"); | ||
800 | break; | 798 | break; |
801 | 799 | ||
802 | default: | 800 | default: |
803 | return -EINVAL; | 801 | return -EINVAL; |
804 | } | 802 | } |
805 | 803 | ||
806 | if (adapter->blink_was_down) { | 804 | if (test_and_clear_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state)) { |
807 | qlcnic_diag_free_res(dev, max_sds_rings); | 805 | qlcnic_diag_free_res(dev, max_sds_rings); |
808 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 806 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
809 | } | 807 | } |