Sun, Jul 26, 2015 at 07:15:04AM CEST, sfel...@gmail.com wrote:
>On Thu, Jul 23, 2015 at 8:43 AM, Jiri Pirko <j...@resnulli.us> wrote:
>> From: Jiri Pirko <j...@mellanox.com>
>>
>> Add PCI bus implementation for Mellanox Technologies Switch ASICs. This
>> includes firmware initialization, async queues manipulation and command
>> interface implementation.
>>
>> Signed-off-by: Jiri Pirko <j...@mellanox.com>
>> Signed-off-by: Ido Schimmel <ido...@mellanox.com>
>> Signed-off-by: Elad Raz <el...@mellanox.com>
>> ---
>
>[cut]
>
>> +static int mlxsw_pci_fw_area_init(struct mlxsw_pci *mlxsw_pci, char *mbox,
>> +                                 u16 num_pages)
>> +{
>> +       struct mlxsw_pci_mem_item *mem_item;
>> +       int i;
>> +       int err;
>
>Need to init err to zero here

You are right. We need to set err before "goto err_alloc". Thanks.


>
>> +
>> +       mlxsw_pci->fw_area.items = kcalloc(num_pages, sizeof(*mem_item),
>> +                                          GFP_KERNEL);
>> +       if (!mlxsw_pci->fw_area.items)
>> +               return -ENOMEM;
>> +       mlxsw_pci->fw_area.num_pages = num_pages;
>> +
>> +       mlxsw_cmd_mbox_zero(mbox);
>> +       for (i = 0; i < num_pages; i++) {
>> +               mem_item = &mlxsw_pci->fw_area.items[i];
>> +
>> +               mem_item->size = MLXSW_PCI_PAGE_SIZE;
>> +               mem_item->buf = pci_alloc_consistent(mlxsw_pci->pdev,
>> +                                                    mem_item->size,
>> +                                                    &mem_item->mapaddr);
>> +               if (!mem_item->buf)
>> +                       goto err_alloc;
>> +               mlxsw_cmd_mbox_map_fa_pa_set(mbox, i, mem_item->mapaddr);
>> +               mlxsw_cmd_mbox_map_fa_log2size_set(mbox, i, 0); /* 1 page */
>> +       }
>> +
>> +       err = mlxsw_cmd_map_fa(mlxsw_pci->core, mbox, num_pages);
>> +       if (err)
>> +               goto err_cmd_map_fa;
>> +
>> +       return 0;
>> +
>> +err_cmd_map_fa:
>> +err_alloc:
>> +       for (i--; i >= 0; i--) {
>> +               mem_item = &mlxsw_pci->fw_area.items[i];
>> +
>> +               pci_free_consistent(mlxsw_pci->pdev, mem_item->size,
>> +                                   mem_item->buf, mem_item->mapaddr);
>> +       }
>> +       kfree(mlxsw_pci->fw_area.items);
>> +       return err;
>> +}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to