Re: [PATCH 1/3] scsi: fcoe: Statically initialize flogi_maddr

From: Kees Cook
Date: Fri May 28 2021 - 14:30:04 EST


On Fri, May 28, 2021 at 11:28:59AM -0700, Joe Perches wrote:
> On Fri, 2021-05-28 at 11:13 -0700, Kees Cook wrote:
> > In preparation for FORTIFY_SOURCE performing compile-time and run-time
> > field bounds checking for memcpy() using memcpy() with an inline const
> > buffer and instead just statically initialize the destination array
> > directly.
> []
> > diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> []
> > @@ -293,7 +293,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
> >   struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
> >   struct netdev_hw_addr *ha;
> >   struct net_device *real_dev;
> > - u8 flogi_maddr[ETH_ALEN];
> > + u8 flogi_maddr[ETH_ALEN] = FC_FCOE_FLOGI_MAC;
>
> static const
>
> > @@ -442,7 +441,7 @@ static void fcoe_interface_remove(struct fcoe_interface *fcoe)
> >  {
> >   struct net_device *netdev = fcoe->netdev;
> >   struct fcoe_ctlr *fip = fcoe_to_ctlr(fcoe);
> > - u8 flogi_maddr[ETH_ALEN];
> > + u8 flogi_maddr[ETH_ALEN] = FC_FCOE_FLOGI_MAC;
>
> etc...

Hm, good point.

--
Kees Cook