All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver/pci/asihpi.c fix segfault ASI87xx
@ 2005-02-08  0:50 Eliot Blennerhassett
  2005-02-08 20:33 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Eliot Blennerhassett @ 2005-02-08  0:50 UTC (permalink / raw)
  To: alsa-devel

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

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

end of thread, other threads:[~2005-02-08 21:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-08  0:50 [PATCH] driver/pci/asihpi.c fix segfault ASI87xx Eliot Blennerhassett
2005-02-08 20:33 ` Takashi Iwai
2005-02-08 20:56   ` Eliot Blennerhassett
2005-02-08 21:22     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.