]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: seq: oss/rw: allocate evrec with main struct
authorRosen Penev <rosenp@gmail.com>
Thu, 30 Apr 2026 21:04:13 +0000 (14:04 -0700)
committerTakashi Iwai <tiwai@suse.de>
Mon, 4 May 2026 11:24:53 +0000 (13:24 +0200)
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>
Link: https://patch.msgid.link/20260430210413.31185-1-rosenp@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/oss/seq_oss_readq.c
sound/core/seq/oss/seq_oss_readq.h

index c880d47711698add26ed044c59a869fbaf628519..6b474615ced89304dc2d32ea9f2166f8bf6811fe 100644 (file)
@@ -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);
 }
 
 /*
index 38d0c4682b29896ebe984f05201a50516ed8c9c0..d8e1e7504d8fbfabe40e4a03b8aff4694b8c9165 100644 (file)
 #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);