Subject: Re: [PATCH net-next v29 3/3] mctp pcc: Implement MCTP over PCC Transport

From: Simon Horman <[email-masked]>
Date: Fri, 26 Sep 2025 15:16:50 +0100

On Thu, Sep 25, 2025 at 03:00:26PM -0400, Adam Young wrote:

...

> +static int initialize_MTU(struct net_device *ndev)
> +{
> +	struct mctp_pcc_ndev *mctp_pcc_ndev = netdev_priv(ndev);
> +	struct mctp_pcc_mailbox *outbox;
> +	int mctp_pcc_mtu;
> +
> +	outbox = &mctp_pcc_ndev->outbox;
> +	outbox->chan = pcc_mbox_request_channel(&outbox->client, outbox->index);
> +	mctp_pcc_mtu = outbox->chan->shmem_size - sizeof(struct pcc_header);

Hi Adam,

On the line below it is expected that outbox->chan may be an error value
rather than a valid pointer. But on the line above outbox->chan is
dereferenced.

This does not seem consistent.

Flagged by Smatch.

> +	if (IS_ERR(outbox->chan))
> +		return PTR_ERR(outbox->chan);
> +
> +	pcc_mbox_free_channel(mctp_pcc_ndev->outbox.chan);
> +
> +	mctp_pcc_ndev = netdev_priv(ndev);
> +	ndev->mtu = MCTP_MIN_MTU;
> +	ndev->max_mtu = mctp_pcc_mtu;
> +	ndev->min_mtu = MCTP_MIN_MTU;
> +
> +	return 0;
> +}

...

-- 
pw-bot: changes-requested