net/mlxfw: fix a NULL dereference
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 14 Jun 2017 10:41:52 +0000 (13:41 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 14 Jun 2017 19:32:18 +0000 (15:32 -0400)
If we hit this error path we end up returning ERR_PTR(0) which is NULL.
The caller is not expecting that so it results in a NULL dereference.

Fixes: 410ed13cae39 ("Add the mlxfw module for Mellanox firmware flash process")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Yotam Gigi <yotamg@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c

index 628150d28061781aded9ed9cfd1757ef5809bfe3..993cb5ba934ecfc4635d056fb7259d5427943936 100644 (file)
@@ -594,6 +594,7 @@ mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
        if (memcmp(comp_data->buff, mlxfw_mfa2_comp_magic,
                   mlxfw_mfa2_comp_magic_len) != 0) {
                pr_err("Component has wrong magic\n");
+               err = -EINVAL;
                goto err_out;
        }