driver/pci/asihpi.c fix segfault ASI87xx
PATCH 1/1 driver/pci/asihpi.c fix segfault ASI87xx
Sampleclock control was assumed to exist, actually doesn't in some adapters. Add error return checks so use of invalid return value doesn't result (sometimes) in segfault.
--- ../../alsa-driver-1.0.8_clean/pci/asihpi.c 2004-09-23 03:29:17.000000000 +1200
+++ asihpi.c 2005-02-07 16:56:12.000000000 +1300
@@ -1568,8 +1568,8 @@
snd_card_asihpi_t *asihpi = entry->private_data;
HW16 wVersion;
HPI_HCONTROL hControl;
- HW32 dwRate;
- HW16 wSource;
+ HW32 dwRate=0;
+ HW16 wSource=0;
int err;
snd_iprintf(buffer, "ASIHPI driver proc file\n");@@ -1580,7 +1580,7 @@
wVersion = asihpi->wVersion;
snd_iprintf(buffer,
- "S/N=%ld\nHw Version %c%d\nDSP code version %03d\n",
+ "Serial#=%ld\nHw Version %c%d\nDSP code version %03d\n",
asihpi->dwSerialNumber, ((wVersion >> 3) & 0xf) + 'A',
wVersion & 0x7,
((wVersion >> 13) * 100) + ((wVersion >> 7) & 0x3f));
@@ -1589,10 +1589,13 @@
HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
HPI_CONTROL_SAMPLECLOCK, &hControl);- err = HPI_SampleClock_GetSampleRate(phSubSys, hControl, &dwRate); - err = HPI_SampleClock_GetSource(phSubSys, hControl, &wSource); - snd_iprintf(buffer, "SampleClock=%ldHz, source %s\n", dwRate,
- sampleclock_sources[wSource]);
+ if (!err) {
+ err = HPI_SampleClock_GetSampleRate(phSubSys,
hControl, &dwRate);
+ err = HPI_SampleClock_GetSource(phSubSys, hControl,
&wSource);
+ snd_iprintf(buffer, "SampleClock=%ldHz, source %s\n",
dwRate,
+ sampleclock_sources[wSource]);
+ }
+
}
@@ -1671,8 +1674,8 @@
HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
HPI_CONTROL_SAMPLECLOCK, &hControl);- err =
- HPI_SampleClock_SetSampleRate(phSubSys, hControl, adapter_fs);
+ if (!err)
+ err = HPI_SampleClock_SetSampleRate(phSubSys,
hControl, adapter_fs);
snd_asihpi_proc_init(asihpi);
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Hi Eliot,
At Tue, 8 Feb 2005 13:50:28 +1300,
Quoted 4 lines · Eliot Blennerhassett
Sampleclock control was assumed to exist, actually doesn't in some adapters. Add error return checks so use of invalid return value doesn't result (sometimes) in segfault.
Looks like your mailer broke the patch.
Please attach the patch instead of pasting.
Also, don't forget to give "Signed-off-by" for changelog.
thanks,
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 10 lines · Takashi Iwai
Hi Eliot,
At Tue, 8 Feb 2005 13:50:28 +1300,
Quoted 3 lines · Eliot Blennerhassett
Sampleclock control was assumed to exist, actually doesn't in some adapters. Add error return checks so use of invalid return value doesn't result (sometimes) in segfault.
Looks like your mailer broke the patch.
Oops. Thanks for letting me know.
Quoted 1 line
Please attach the patch instead of pasting.
here
Quoted 1 line
Also, don't forget to give "Signed-off-by" for changelog.
OK this time I hope
-- Eliot
asihpi.c renamed from ../alsa-driver-1.0.8_clean/pci/asihpi.c +14 -9
@@ -1568,8 +1568,8 @@snd_card_asihpi_t *asihpi = entry->private_data;HW16 wVersion;HPI_HCONTROL hControl; -HW32 dwRate; -HW16 wSource; +HW32 dwRate=0 ; +HW16 wSource=0 ;int err;snd_iprintf (buffer,"ASIHPI driver proc file\n" );
@@ -1580,7 +1580,7 @@ wVersion = asihpi->wVersion;snd_iprintf (buffer, -"S/N=%ld\nHw Version %c%d\nDSP code version %03d\n" , +"Serial#=%ld\nHw Version %c%d\nDSP code version %03d\n" , asihpi->dwSerialNumber, ((wVersion >>3 ) &0xf ) +'A' , wVersion &0x7 , ((wVersion >>13 ) *100 ) + ((wVersion >>7 ) &0x3f ));
@@ -1589,10 +1589,15 @@HPI_SOURCENODE_CLOCK_SOURCE ,0 ,0 ,0 , HPI_CONTROL_SAMPLECLOCK, &hControl); - err =HPI_SampleClock_GetSampleRate (phSubSys, hControl, &dwRate); - err =HPI_SampleClock_GetSource (phSubSys, hControl, &wSource); -snd_iprintf (buffer,"SampleClock=%ldHz, source %s\n" , dwRate, - sampleclock_sources[wSource]); +if (!err) { + err =HPI_SampleClock_GetSampleRate (phSubSys, hControl, &dwRate); + err +=HPI_SampleClock_GetSource (phSubSys, hControl, &wSource); + +if (!err) +snd_iprintf (buffer,"SampleClock=%ldHz, source %s\n" , dwRate, + sampleclock_sources[wSource]); + } + }
@@ -1671,8 +1676,8 @@HPI_SOURCENODE_CLOCK_SOURCE ,0 ,0 ,0 , HPI_CONTROL_SAMPLECLOCK, &hControl); - err = -HPI_SampleClock_SetSampleRate (phSubSys, hControl, adapter_fs); +if (!err) + err =HPI_SampleClock_SetSampleRate (phSubSys, hControl, adapter_fs);snd_asihpi_proc_init (asihpi);
At Wed, 9 Feb 2005 09:56:11 +1300,
Quoted 17 lines · Eliot Blennerhassett
Quoted 10 lines · Takashi Iwai
Hi Eliot,
At Tue, 8 Feb 2005 13:50:28 +1300,
Quoted 3 lines · Eliot Blennerhassett
Sampleclock control was assumed to exist, actually doesn't in some adapters. Add error return checks so use of invalid return value doesn't result (sometimes) in segfault.
Looks like your mailer broke the patch.
Oops. Thanks for letting me know.
Quoted 1 line
Please attach the patch instead of pasting.
Quoted 7 lines
here
Quoted 1 line
Also, don't forget to give "Signed-off-by" for changelog.
Signed-off-by Eliot Blennerhassett <[email protected]>OK this time I hope
Thanks, now applied to CVS.
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click