Re: [PATCH] staging: greybus: fix fw is NULL but dereferenced.

Johan Hovold
2020-01-26T11:04:43Z

On Sun, Jan 26, 2020 at 02:01:30PM +0530, Saurav Girepunje wrote:
> Fix the warning reported by cocci check.
>
> Changes:
>
> In queue_work fw dereference before it actually get assigned.
> move queue_work before gb_bootrom_set_timeout.

Nope. As I said yesterday, you need to verify the output of any static
checkers you use.

The code may be unnecessarily subtle, but there's no way fw can be
dereferenced before being initialised currently.

> -queue_work:
> /* Refresh timeout */
> if (!ret && (offset + size == fw->size))

Specifically, the second operand is never evaluated if ret is non-zero.

> next_request = NEXT_REQ_READY_TO_BOOT;
> - else
> - next_request = NEXT_REQ_GET_FIRMWARE;
>
> +queue_work:
> gb_bootrom_set_timeout(bootrom, next_request, NEXT_REQ_TIMEOUT_MS);
>
> return ret;

Johan