Skip to contentSkip to conversation

solo6x10: use designated initializers

PATCH In review Kees Cook 3 participants 4 messages Dec 17, 2016 – Jan 8, 2017

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 solo6x10: use designated initializers

Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. These were identified during allyesconfig builds of x86, arm, and arm64, with most initializer fixes extracted from grsecurity.

---
 drivers/media/pci/solo6x10/solo6x10-g723.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
index 6a35107aca25..36e93540bb49 100644
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-	static struct snd_device_ops ops = { NULL };
+	static struct snd_device_ops ops = { };
 	struct snd_card *card;
 	struct snd_kcontrol_new kctl;
 	char name[32];
Signature · 6 lines
2.7.4


-- 
Kees Cook
Nexus Security
#1 lore raw
Quoted 4 lines · Kees Cook

Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. These were identified during allyesconfig builds of x86, arm, and arm64, with most initializer fixes extracted from grsecurity.

Ok I've reviewed all the patchset, googled a bit and now I see what's going on.

Quoted 11 lines
---
 drivers/media/pci/solo6x10/solo6x10-g723.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/solo6x10/solo6x10-g723.c +0 -0
index 6a35107aca25..36e93540bb49 100644

drivers/media/pci/solo6x10/solo6x10-g723.c static int solo_snd_pcm_init(struct solo_dev *solo_dev) · line 353

Quoted 5 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-	static struct snd_device_ops ops = { NULL };
+	static struct snd_device_ops ops = { };

I'm not that keen on syntax subtleties, but...
* Empty initializer is not quite "designated" as I can judge.
* From brief googling I see that empty initializer is not valid in some C standards.

Since ops is static, what about this?
For the variant given below, you have my signoff.

Quoted 8 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-	static struct snd_device_ops ops = { NULL };
+	static struct snd_device_ops ops;
author
#2 lore raw
Quoted 34 lines · Andrey Utkin
Quoted 4 lines · Kees Cook

Prepare to mark sensitive kernel structures for randomization by making sure they're using designated initializers. These were identified during allyesconfig builds of x86, arm, and arm64, with most initializer fixes extracted from grsecurity.

Ok I've reviewed all the patchset, googled a bit and now I see what's going on.

Quoted 11 lines
---
 drivers/media/pci/solo6x10/solo6x10-g723.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/solo6x10/solo6x10-g723.c +0 -0
index 6a35107aca25..36e93540bb49 100644

drivers/media/pci/solo6x10/solo6x10-g723.c static int solo_snd_pcm_init(struct solo_dev *solo_dev) · line 353

Quoted 5 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-     static struct snd_device_ops ops = { NULL };
+     static struct snd_device_ops ops = { };

I'm not that keen on syntax subtleties, but...
* Empty initializer is not quite "designated" as I can judge.
* From brief googling I see that empty initializer is not valid in some C standards.

Since ops is static, what about this?
For the variant given below, you have my signoff.

Quoted 8 lines

drivers/media/pci/solo6x10/solo6x10-g723.c static int solo_snd_pcm_init(struct solo_dev *solo_dev) · line 353

Quoted 8 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-     static struct snd_device_ops ops = { NULL };
+     static struct snd_device_ops ops;

Ah! Yes, thanks. That works fine too. :) Can this be const as well?

-Kees

Signature · 2 lines
Kees Cook
Nexus Security
#3 lore raw
Quoted 7 lines · Kees Cook
Quoted 7 lines

Since ops is static, what about this?
For the variant given below, you have my signoff.

Quoted 4 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +0 -0
@@ -350,7 +350,7 @@ static int solo_snd_pcm_init(struct solo_dev *solo_dev)
 
Quoted 6 lines
Quoted 4 lines

drivers/media/pci/solo6x10/solo6x10-g723.c static int solo_snd_pcm_init(struct solo_dev *solo_dev)

Quoted 4 lines
drivers/media/pci/solo6x10/solo6x10-g723.c +1 -1
 int solo_g723_init(struct solo_dev *solo_dev)
 {
-     static struct snd_device_ops ops = { NULL };
+     static struct snd_device_ops ops;

Ah! Yes, thanks. That works fine too. :) Can this be const as well?

No, it can't be const, it's used as parameter for snd_device_new() which takes "struct snd_device_ops *".