Re: [PATCH RESEND v4 2/2] ALSA: control: add ioctl to retrieve full card components
From: Jaroslav Kysela
Date: Thu Jun 25 2026 - 08:49:58 EST
On 6/25/26 14:07, Maciej Strozek wrote:
...
+struct snd_ctl_card_bytes {
+ unsigned int type; /* SND_CTL_CARD_BTYPE_* */
+ unsigned int data_allocated; /* size of @data buffer in bytes */
+ unsigned int data_len; /* in/out: actual data length in bytes */
+ unsigned char *data; /* user buffer */
I know that I suggested to add code to the compat layer. But it seems that new UAPIs are using just '__u64 data' here with padding to 8 bytes (I would add new reserved field and perhaps we may use force `__u32' type for all other fields). The code in kernel sound translate the u64 data to pointer using u64_to_user_ptr() function.
So like:
struct snd_ctl_card_bytes {
__u32 type;
__u32 data_allocated;
__u32 data_len;
__u32 reserved; /* explicit pad */
__u64 data; /* pointer as __u64 */
};
+static int snd_ctl_card_bytes(struct snd_card *card,
+ struct snd_ctl_card_bytes *info,
+ unsigned int __user *data_len_out)
+{
+ unsigned int data_len;
+
+ switch (info->type) {
+ case SND_CTL_CARD_BTYPE_COMPONENTS:
+ scoped_guard(rwsem_read, &snd_ioctl_rwsem) {
+ data_len = strlen(card->components) + 1;
The field card->components may be NULL here, also fix other uses like in snd_ctl_card_info().
Thank you,
Jaroslav
--
Jaroslav Kysela <perex@xxxxxxxx>
Linux Sound Maintainer; ALSA Project; Red Hat