Bug 188761 - Function load_asic() returns an improper error code when the call to load_asic_generic() fails
Summary: Function load_asic() returns an improper error code when the call to load_asi...
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:56 UTC by bianpan
Modified: 2016-11-29 19:01 UTC (History)
1 user (show)

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Fix the bug 188761 (1.09 KB, patch)
2016-11-29 02:50 UTC, bianpan
Details | Diff

Description bianpan 2016-11-25 10:56:38 UTC
Function load_asic_generic() returns a negative value on failure. In the function load_asic() defined in file sound/pci/echoaudio/layla24_dsp.c, the return value of load_asic_generic() is checked (at line 137). However, it returns false (real value of which is 0, indicates success) when load_asic_generic() returns a negative value. Maybe the author intends to return "err". Codes related to this bug are summarised as follows.

load_asic @@ sound/pci/echoaudio/layla24_dsp.c
112 static int load_asic(struct echoaudio *chip)
113 {
114     int err;
115 
116     if (chip->asic_loaded)
117         return 1;
        ...
133 
134     /* Do the external one */
135     err = load_asic_generic(chip, DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC,
136                 FW_LAYLA24_2S_ASIC);
137     if (err < 0)
138         return false;       // return err?
139 
140     /* Now give the external ASIC a little time to set up */
141     mdelay(10);
142 
143     /* See if it worked */
144     err = check_asic_status(chip);
145 
146     /* Set up the control register if the load succeeded -
147        48 kHz, internal clock, S/PDIF RCA mode */
148     if (!err)
149         err = write_control_reg(chip, GML_CONVERTER_ENABLE | GML_48KHZ,
150                     true);
151 
152     return err;
153 }

Thanks very much!
Comment 1 Takashi Iwai 2016-11-25 11:20:57 UTC
Yes, obviously it's a logic failure.
Care to submit a fix patch?  Thanks!
Comment 2 bianpan 2016-11-29 02:50:48 UTC
Created attachment 246141 [details]
Fix the bug 188761

This patch fixes the bug 188761. Replace "return false;" with "return err;" at line 138.

Thanks for your attention!
Comment 3 Takashi Iwai 2016-11-29 19:01:16 UTC
Thanks!  I submitted the patch to ML, and am going to merge it later.

Note You need to log in before you can comment on or make changes to this bug.