[PATHv2 2/9] net: sandbox: fix NULL pointer derefences

Maxim Uvarov maxim.uvarov at linaro.org
Tue Dec 26 07:18:07 CET 2023


On Tue, 26 Dec 2023 at 04:43, Sean Anderson <seanga2 at gmail.com> wrote:

> On 12/25/23 10:39, Maxim Uvarov wrote:
> > Add additional checks for NULL pointers.
> >
> > Signed-off-by: Maxim Uvarov <maxim.uvarov at linaro.org>
> > ---
> >   drivers/net/sandbox.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/net/sandbox.c b/drivers/net/sandbox.c
> > index 13022addb6..d91935e032 100644
> > --- a/drivers/net/sandbox.c
> > +++ b/drivers/net/sandbox.c
> > @@ -65,6 +65,9 @@ int sandbox_eth_arp_req_to_reply(struct udevice *dev,
> void *packet,
> >       struct ethernet_hdr *eth_recv;
> >       struct arp_hdr *arp_recv;
> >
> > +     if (!priv)
> > +             return -EAGAIN;
> > +
>
> When can priv be NULL?
>
> --Sean
>
>
Function
struct eth_sandbox_priv *priv = dev_get_priv(dev)
can return NULL. If you ask why it doesn't return NULL without lwip patches
and can return NULL with lwip patch while there is no clear code
dependency..
Then I can not say right now and need additional investigation. But anyway
the return code of dev_dev_priv() has to be checked I think.

BR,
Maxim.



> >       if (ntohs(eth->et_protlen) != PROT_ARP)
> >               return -EAGAIN;
> >
>
>


More information about the U-Boot mailing list