Netdev List
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Andrew Lunn <andrew@lunn.ch>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: ethernet: ax88796: initialize all fields of eeprom_93cx6 struct
Date: Fri, 24 Jul 2026 17:05:07 +0100	[thread overview]
Message-ID: <20260724170507.492ffb61@pumpkin> (raw)
In-Reply-To: <20260724150403.GA56515@wp.pl>

On Fri, 24 Jul 2026 17:04:03 +0200
Stanislaw Gruszka <stf_xl@wp.pl> wrote:

> On Fri, Jul 24, 2026 at 02:57:33PM +0200, Andrew Lunn wrote:
> > On Fri, Jul 24, 2026 at 10:34:11AM +0200, stf_xl@wp.pl wrote:  
> > > From: Stanislaw Gruszka <stf_xl@wp.pl>
> > > 
> > > Commit 7738a7ab9d12 ("misc: eeprom: eeprom_93cx6: Add quirk for extra
> > > read clock cycle") added extra 'quirk' field to struct eeprom_93cx6,
> > > which change how the data is read.
> > > 
> > > Some existing users of eeprom_93cx6, including ax88796 driver, allocate
> > > the structure on the stack without initialization of all the fields.
> > > As a result, the added quirk field has undefined value, what can
> > > randomly cause reading wrong data from the EEPROM.
> > > 
> > > Fix by using designated initialization.  
> > 
> > The problem with this solution is that the next time another member is
> > added, it breaks again.  
> 
> I did not initialized 'quirks' explicitly in the patch.
> 
> > struct eeprom_93cx6 eeprom = {0};
> > 
> > Will initialise all fields to 0, and then you can use the existing
> > code to set those fields as needed.  
> 
> This form:
> 		struct eeprom_93cx6 eeprom = {
> 			.data = ei_local,
> 			.register_read = ax_eeprom_register_read,
> 			.register_write = ax_eeprom_register_write,
> 			.width = PCI_EEPROM_WIDTH_93C56,
> 		};
> 
> will also initialize _all_ remaining fields to zero.
> 
> I believe it is guaranteed by C standard.

Unless there are unions or padding...

	David

> 
> Regards
> Stanislaw
> 


  reply	other threads:[~2026-07-24 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24  8:34 [PATCH] net: ethernet: ax88796: initialize all fields of eeprom_93cx6 struct stf_xl
2026-07-24 12:57 ` Andrew Lunn
2026-07-24 15:04   ` Stanislaw Gruszka
2026-07-24 16:05     ` David Laight [this message]
2026-07-24 13:04 ` Vadim Fedorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260724170507.492ffb61@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stf_xl@wp.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox