summaryrefslogtreecommitdiffstats
path: root/sound/firewire/fcp.c
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2017-04-03 08:13:55 -0400
committerTakashi Iwai <tiwai@suse.de>2017-04-05 15:37:23 -0400
commit7e1621de146fbed6172252f14a6a41b2c5999a93 (patch)
tree244737dfe7058e9e958aee74358526c2656d5106 /sound/firewire/fcp.c
parent5b33504bada4d85092b69b3aaa7048c398b21dbb (diff)
ALSA: firewire-lib/bebob/oxfw: improve response evaluation for AV/C commands
In ALSA firewire stack, some AV/C commands are supported, including vendor's extensions. Drivers includes response parser of each command, according to its requirements, while the parser is written with loose fashion in two points; error check and length check. This doesn't cause any issues such as kernel corruption, but should be improved. This commit modifies evaluations of return value on each parsers. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/fcp.c')
-rw-r--r--sound/firewire/fcp.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c
index cce19768f43d..61dda828f767 100644
--- a/sound/firewire/fcp.c
+++ b/sound/firewire/fcp.c
@@ -63,7 +63,9 @@ int avc_general_set_sig_fmt(struct fw_unit *unit, unsigned int rate,
63 /* do transaction and check buf[1-5] are the same against command */ 63 /* do transaction and check buf[1-5] are the same against command */
64 err = fcp_avc_transaction(unit, buf, 8, buf, 8, 64 err = fcp_avc_transaction(unit, buf, 8, buf, 8,
65 BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5)); 65 BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5));
66 if (err >= 0 && err < 8) 66 if (err < 0)
67 ;
68 else if (err < 8)
67 err = -EIO; 69 err = -EIO;
68 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ 70 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
69 err = -ENOSYS; 71 err = -ENOSYS;
@@ -106,7 +108,9 @@ int avc_general_get_sig_fmt(struct fw_unit *unit, unsigned int *rate,
106 /* do transaction and check buf[1-4] are the same against command */ 108 /* do transaction and check buf[1-4] are the same against command */
107 err = fcp_avc_transaction(unit, buf, 8, buf, 8, 109 err = fcp_avc_transaction(unit, buf, 8, buf, 8,
108 BIT(1) | BIT(2) | BIT(3) | BIT(4)); 110 BIT(1) | BIT(2) | BIT(3) | BIT(4));
109 if (err >= 0 && err < 8) 111 if (err < 0)
112 ;
113 else if (err < 8)
110 err = -EIO; 114 err = -EIO;
111 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ 115 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
112 err = -ENOSYS; 116 err = -ENOSYS;
@@ -154,7 +158,9 @@ int avc_general_get_plug_info(struct fw_unit *unit, unsigned int subunit_type,
154 buf[3] = 0xff & subfunction; 158 buf[3] = 0xff & subfunction;
155 159
156 err = fcp_avc_transaction(unit, buf, 8, buf, 8, BIT(1) | BIT(2)); 160 err = fcp_avc_transaction(unit, buf, 8, buf, 8, BIT(1) | BIT(2));
157 if (err >= 0 && err < 8) 161 if (err < 0)
162 ;
163 else if (err < 8)
158 err = -EIO; 164 err = -EIO;
159 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ 165 else if (buf[0] == 0x08) /* NOT IMPLEMENTED */
160 err = -ENOSYS; 166 err = -ENOSYS;