Bug 189101 - Function qlcnic_83xx_test_link() returns improper value when the call to qlcnic_alloc_mbx_args() fails
Summary: Function qlcnic_83xx_test_link() returns improper value when the call to qlcn...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Network (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_network@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 11:23 UTC by bianpan
Modified: 2016-11-25 11:23 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description bianpan 2016-11-25 11:23:42 UTC
qlcnic_83xx_test_link @@ drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
In function qlcnic_83xx_test_link() is defined in file drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c, the local variable config takes the return value. However, when the call to qlcnic_alloc_mbx_args() (at line 3190) fails, it returns variable err. In this case, the value of err is a negative integer, which is not an expected value of its callers, e.g. qlcnic_83xx_get_settings(). I guess "return err;" may be a typo. Does the author intends to return "config"? Codes related to this bug are summarised as follows.

3171 int qlcnic_83xx_test_link(struct qlcnic_adapter *adapter)
3172 {
3173     u8 pci_func;
3174     int err;
3175     u32 config = 0, state;
3176     struct qlcnic_cmd_args cmd;
3177     struct qlcnic_hardware_context *ahw = adapter->ahw;
3178 
3179     if (qlcnic_sriov_vf_check(adapter))
3180         pci_func = adapter->portnum;
3181     else
3182         pci_func = ahw->pci_func;
3183 
3184     state = readl(ahw->pci_base0 + QLC_83XX_LINK_STATE(pci_func));
3185     if (!QLC_83xx_FUNC_VAL(state, pci_func)) {
3186         dev_info(&adapter->pdev->dev, "link state down\n");
3187         return config;
3188     }
3189 
3190     err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_GET_LINK_STATUS);
3191     if (err)
             // Bug. "return config;" ?
3192         return err;
         ...
3250 out:
3251     qlcnic_free_mbx_args(&cmd);
3252     return config;
3253 }

qlcnic_83xx_get_settings @@ drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
3255 int qlcnic_83xx_get_settings(struct qlcnic_adapter *adapter,
3256                  struct ethtool_cmd *ecmd)
3257 {
3258     struct qlcnic_hardware_context *ahw = adapter->ahw;
3259     u32 config = 0;
3260     int status = 0;
3261 
3262     if (!test_bit(__QLCNIC_MAINTENANCE_MODE, &adapter->state)) {
3263         /* Get port configuration info */
3264         status = qlcnic_83xx_get_port_info(adapter);
3265         /* Get Link Status related info */
3266         config = qlcnic_83xx_test_link(adapter);
        // if the value of config is negative, the value of ahw->module_type may be illegal  
3267         ahw->module_type = QLC_83XX_SFP_MODULE_TYPE(config);
3268     }
         ...
3347     return status;
3348 }

Thanks very much!

Note You need to log in before you can comment on or make changes to this bug.