diff mbox series

[alsa-lib] control: Make ump_{endpoint|block}_info calls optional

Message ID 20240815144103.13141-1-tiwai@suse.de (mailing list archive)
State New, archived
Headers show
Series [alsa-lib] control: Make ump_{endpoint|block}_info calls optional | expand

Commit Message

Takashi Iwai Aug. 15, 2024, 2:41 p.m. UTC
Add the NULL check for ump_endpoint_info and ump_block_info calls.
Those can be NULl depending on the target.

Fixes: 81b0cf46d16a ("control: Add UMP Endpoint and Block info query support")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 src/control/control.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/control/control.c b/src/control/control.c
index d77ab24cc69c..e443d5436103 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -1293,7 +1293,10 @@  int snd_ctl_ump_next_device(snd_ctl_t *ctl, int *device)
 int snd_ctl_ump_endpoint_info(snd_ctl_t *ctl, snd_ump_endpoint_info_t *info)
 {
 	assert(ctl && info);
-	return ctl->ops->ump_endpoint_info(ctl, info);
+	fprintf(stderr, "%s:%d\n", __func__, __LINE__);
+	if (ctl->ops->ump_endpoint_info)
+		return ctl->ops->ump_endpoint_info(ctl, info);
+	return -ENXIO;
 }
 
 /**
@@ -1305,7 +1308,9 @@  int snd_ctl_ump_endpoint_info(snd_ctl_t *ctl, snd_ump_endpoint_info_t *info)
 int snd_ctl_ump_block_info(snd_ctl_t *ctl, snd_ump_block_info_t *info)
 {
 	assert(ctl && info);
-	return ctl->ops->ump_block_info(ctl, info);
+	if (ctl->ops->ump_block_info)
+		return ctl->ops->ump_block_info(ctl, info);
+	return -ENXIO;
 }
 
 /**