Patrick Wildt <patr...@blueri.se> wrote:

> On Fri, Aug 06, 2021 at 11:05:53AM +0200, Patrick Wildt wrote:
> > Am Thu, Aug 05, 2021 at 02:33:01PM +0200 schrieb Jan Klemkow:
> > > Hi,
> > > 
> > > The following diff removes useless code from the driver.  As discussed
> > > here [1] and committed there [2], the hypervisor doesn't do anything
> > > with the data structures.  We even just set NULL to the pointer since
> > > the initial commit of vmx(4).  So, I guess it better to remove all of
> > > these.  The variables are bzero'd in vmxnet3_dma_allocmem() anyway.
> > > 
> > > OK?
> > 
> > My main concern was if the structs are getting zeroed correctly, but
> > they do, so that's fine.
> > 
> > That said, it looks like Linux sets the pointer to ~0ULL, not 0.  Should
> > we follow Linux' pattern there and do that as well?
> > 
> 
> Thinking about it a little more, I think we should do that as well.  And
> maybe explicitly set driver_data_len to 0 even though it's already zero.
> Basically for readability.

The better approach is to zero the whole struct, then fill in non-zero
fields... and fill in zero'd fields when doing so idiomaticaly helps
future code readers.

But if you avoid zero'ing the whole struct, then padding bytes in the
struct may be a problem, and depending on the allocator and where the
data is later passed to, leak.

So full structure zero is the best practice.

Reply via email to