Subject: Re: [PATCH] net: sh_eth: avoid NULL pointer dereference in ring setup

From: Sergei Shtylyov <[email-masked]>
Date: Wed, 2 Mar 2016 19:47:05 +0300

Hello.

On 03/02/2016 06:26 PM, Wolfram Sang wrote:

> From: Wolfram Sang <[email-masked]>
>
> When allocating an skb fails, rxdesc is still NULL (or the previous ring
> index on further iterations of the loop). However, this pointer is
> dereferenced after the loop.

    This is intended. What we seem to actually need is a NULL check before 
that dereference.

> So, make sure rxdesc is updated immediately
> at the beginning of the loop.

    No, this seems wrong. We don't want an unfilled descriptor to be marked as 
last, we still need the previous one marked as last. Actually, 'rxdesc' 
shouldn't be "advanced" even before the second *break* as it is now.

> Reported-by: coverity (CID 1056464)
> Signed-off-by: Wolfram Sang <[email-masked]>

    Will you respin or should I?

MBR, Sergei