public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: seq: oss/rw: allocate evrec with main struct
@ 2026-04-30 21:04 Rosen Penev
  2026-05-04 11:25 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-04-30 21:04 UTC (permalink / raw)
  To: linux-sound
  Cc: Jaroslav Kysela, Takashi Iwai, Kees Cook, Gustavo A. R. Silva,
	open list,
	open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b

Use a flexible array member to simplify allocation slightly.

Add the header as flexible array members require full definitions.

Remove null check and just kfree. The former is not needed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 sound/core/seq/oss/seq_oss_readq.c | 13 ++-----------
 sound/core/seq/oss/seq_oss_readq.h |  3 ++-
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c
index c880d4771169..6b474615ced8 100644
--- a/sound/core/seq/oss/seq_oss_readq.c
+++ b/sound/core/seq/oss/seq_oss_readq.c
@@ -34,16 +34,10 @@ snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen)
 {
 	struct seq_oss_readq *q;
 
-	q = kzalloc_obj(*q);
+	q = kzalloc_flex(*q, q, maxlen);
 	if (!q)
 		return NULL;
 
-	q->q = kzalloc_objs(union evrec, maxlen);
-	if (!q->q) {
-		kfree(q);
-		return NULL;
-	}
-
 	q->maxlen = maxlen;
 	q->qlen = 0;
 	q->head = q->tail = 0;
@@ -61,10 +55,7 @@ snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen)
 void
 snd_seq_oss_readq_delete(struct seq_oss_readq *q)
 {
-	if (q) {
-		kfree(q->q);
-		kfree(q);
-	}
+	kfree(q);
 }
 
 /*
diff --git a/sound/core/seq/oss/seq_oss_readq.h b/sound/core/seq/oss/seq_oss_readq.h
index 38d0c4682b29..d8e1e7504d8f 100644
--- a/sound/core/seq/oss/seq_oss_readq.h
+++ b/sound/core/seq/oss/seq_oss_readq.h
@@ -10,13 +10,13 @@
 #define __SEQ_OSS_READQ_H
 
 #include "seq_oss_device.h"
+#include "seq_oss_event.h"
 
 
 /*
  * definition of read queue
  */
 struct seq_oss_readq {
-	union evrec *q;
 	int qlen;
 	int maxlen;
 	int head, tail;
@@ -24,6 +24,7 @@ struct seq_oss_readq {
 	unsigned long input_time;
 	wait_queue_head_t midi_sleep;
 	spinlock_t lock;
+	union evrec q[] __counted_by(maxlen);
 };
 
 struct seq_oss_readq *snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen);
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: seq: oss/rw: allocate evrec with main struct
  2026-04-30 21:04 [PATCH] ALSA: seq: oss/rw: allocate evrec with main struct Rosen Penev
@ 2026-05-04 11:25 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-05-04 11:25 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-sound, Jaroslav Kysela, Takashi Iwai, Kees Cook,
	Gustavo A. R. Silva, open list,
	open list:KERNEL HARDENING (not covered by other areas)__counted_by:Keyword:b(_le|_be)?b

On Thu, 30 Apr 2026 23:04:13 +0200,
Rosen Penev wrote:
> 
> Use a flexible array member to simplify allocation slightly.
> 
> Add the header as flexible array members require full definitions.
> 
> Remove null check and just kfree. The former is not needed.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

Applied to for-next branch.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-04 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 21:04 [PATCH] ALSA: seq: oss/rw: allocate evrec with main struct Rosen Penev
2026-05-04 11:25 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox