Alsa-Devel Archive on
 help / color / Atom feed
* [alsa-devel] [PATCH] ALSA: ctl: allow TLV read operation for callback type of element in locked case
@ 2019-12-23  9:33 Takashi Sakamoto
  2019-12-23  9:42 ` Takashi Sakamoto
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Takashi Sakamoto @ 2019-12-23  9:33 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel

A design of ALSA control core allows applications to execute three
operations for TLV feature; read, write and command. Furthermore, it
allows driver developers to process the operations by two ways; allocated
array or callback function. In the former, read operation is just allowed,
thus developers uses the latter when device driver supports variety of
models or the target model is expected to dynamically change information
stored in TLV container.

The core also allows applications to lock any element so that the other
applications can't perform write operation to the element for element
value and TLV information. When the element is locked, write and command
operation for TLV information are prohibited as well as element value.
Any read operation should be allowed in the case.

At present, when an element has callback function for TLV information,
TLV read operation returns EPERM if the element is locked. On the
other hand, the read operation is success when an element has allocated
array for TLV information. In both cases, read operation is success for
element value expectedly.

This commit fixes the bug. This change can be backported to v4.14
kernel or later.
 sound/core/control.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 3fa1171dc1c2..49f3428dfacb 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1398,8 +1398,9 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag,
 	if (kctl->tlv.c == NULL)
 		return -ENXIO;
-	/* When locked, this is unavailable. */
-	if (vd->owner != NULL && vd->owner != file)
+	// Write and command operations are not allowed for locked element.
+	if (op_flag != SNDRV_CTL_TLV_OP_READ &&
+	    vd->owner != NULL && vd->owner != file)
 		return -EPERM;
 	return kctl->tlv.c(kctl, op_flag, size, buf);

Alsa-devel mailing list

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23  9:33 [alsa-devel] [PATCH] ALSA: ctl: allow TLV read operation for callback type of element in locked case Takashi Sakamoto
2019-12-23  9:42 ` Takashi Sakamoto
2019-12-23 15:03 ` Takashi Iwai
2019-12-24 10:02   ` Takashi Sakamoto
2019-12-24 14:31     ` Takashi Iwai
2019-12-24 12:56 ` Jaroslav Kysela

Alsa-Devel Archive on

Archives are clonable:
	git clone --mirror alsa-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 alsa-devel alsa-devel/ \
	public-inbox-index alsa-devel

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone