[alsa-devel] Uninitialized id returned by saffirepro_both_clk_src_get.

Christian Vogel vogelchr at vogel.cx
Sat Oct 25 13:40:40 CEST 2014


Hi,

there's a possibility to get a Oops caused by an uninitialized value
in snd_bebob_stream_check_internal_clock for a SaffirePro running on the
internal clock.

	[   88.100531] BUG: unable to handle kernel paging request at 8a3c85fc          
	[   88.103808] IP: [<e8553aa0>] snd_bebob_stream_check_internal_clock+0x66/0x11e [snd_bebob]

...which is dereferencing of clk_spec->labels[id] in...

	sound/firewire/bebob/bebob_stream.c :

	/* 1.The device has its own operation to switch source of clock */
	if (clk_spec) {
		err = clk_spec->get(bebob, &id);
		if (err < 0)
			dev_err(&bebob->unit->device,
				"fail to get clock source: %d\n", err);
-->		else if (strncmp(clk_spec->labels[id], SND_BEBOB_CLOCK_INTERNAL,
				 strlen(SND_BEBOB_CLOCK_INTERNAL)) == 0)
			*internal = true;
		goto end;
	}

id is uninitialized, and will not be set by clk_spec->get (which is
saffirepro_both_clk_src_get(), even if it returns ok(0).

Attached patch tries to clean up the logic in saffirepro_both_clk_src_get()
and also adds a safety check to snd_bebob_stream_check_internal_clock().

Thanks for Takashi Sakamoto to whom I sent the patch initially and who
suggested some cleanup to my code, reviewed the patch and suggested I send
it to alsa-dev.

	Chris



More information about the Alsa-devel mailing list