Project

General

Profile

Bug #13046

i40e_device_find() ASSERTs that num_ports and num_partitions are non-zero, but i40e_parse_discover_capabilities() can return with them being zero

Added by Randy Fishel 4 months ago. Updated 4 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

In the function i40e_parse_discover_capabilities(), the i40e_hw elements of num_ports and num_partitions are initialized to zero; such that if the driver fails to discover any active ports, both values will be zero after the function returns. Yet in i40e_device_find, it is ASSRT'd that both values are non-zero; and further tries to use values later that are expected to be non-zero.

Instead, the function should check if either value is non-zero and return a NULL i40e_device_t (callers check to see if the return is NULL, and will fail the configuration).

Suggested code:

                /*
                 * Though remote, it is possible that both ports and partitions
                 * can be zero.  Though it is possible that this is a temporary
                 * condition, this driver doesn't have a way of being restarted,
                 * so we fail here and maybe a future attach will be better.
                 */
                if (hw->num_ports == 0 || hw->num_partitions == 0) {
                        i40e_error(i40e, "Device doesn't have ports or partitions");
                        return (NULL);
                }

Related issues

Related to illumos gate - Bug #9601: Divide by zero in i40e_get_available_resources()ClosedMarcel Telka2018-06-14

Actions
#1

Updated by Marcel Telka 4 months ago

  • Description updated (diff)
#2

Updated by Marcel Telka 4 months ago

  • Related to Bug #9601: Divide by zero in i40e_get_available_resources() added
#3

Updated by Marcel Telka 4 months ago

Unfortunately, the i40e_device_find() caller does not accept NULL as return value and would panic at line 1030:

995    idp = i40e_device_find(i40e, parent, bus, device);
996    i40e->i40e_device = idp;

...

1030    for (i = 0; i < idp->id_rsrcs_act; i++) {
1031        i40e_switch_rsrc_t *srp = &i40e->i40e_switch_rsrcs[i];
#4

Updated by Randy Fishel 4 months ago

The suggested fix above is incomplete. The original prototype also added checking the NULL return from i40e_device_find() in i40e_get_available_resources(), and if it is NULL, return. It is from there that the proper thing will happen.

Also available in: Atom PDF