alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH TINYCOMPRESS 13/14] compress: Prevent divide-by-zero faults in get_hpointer()
@ 2013-02-10  0:22 Richard Fitzgerald
  2013-02-22 16:09 ` Richard Fitzgerald
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-10  0:22 UTC (permalink / raw)
  To: vinod.koul; +Cc: alsa-devel

Do not assume that the returned snd_compr_avail contains a
snd_compr_tstamp with a valid sampling_rate. Check for zero
before attempting to use it.

diff --git a/compress.c b/compress.c
index cfd0219..c0e81a3 100644
--- a/compress.c
+++ b/compress.c
@@ -297,10 +297,15 @@ int compress_get_hpointer(struct compress *compress,
 	if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &kavail))
 		return oops(compress, errno, "cannot get avail");
 	*avail = (unsigned int)kavail.avail;
-	time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate;
-	tstamp->tv_sec = time;
-	time = kavail.tstamp.pcm_io_frames % kavail.tstamp.sampling_rate;
-	tstamp->tv_nsec = time * 1000000000 / kavail.tstamp.sampling_rate;
+	if (kavail.tstamp.sampling_rate != 0) {
+		time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate;
+		tstamp->tv_sec = time;
+		time = kavail.tstamp.pcm_io_frames % kavail.tstamp.sampling_rate;
+		tstamp->tv_nsec = time * 1000000000 / kavail.tstamp.sampling_rate;
+	} else {
+		tstamp->tv_sec = 0;
+		tstamp->tv_nsec = 0;
+	}
 	return 0;
 }
 
-- 
1.7.2.5

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

* Re: [PATCH TINYCOMPRESS 13/14] compress: Prevent divide-by-zero faults in get_hpointer()
  2013-02-10  0:22 [PATCH TINYCOMPRESS 13/14] compress: Prevent divide-by-zero faults in get_hpointer() Richard Fitzgerald
@ 2013-02-22 16:09 ` Richard Fitzgerald
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Fitzgerald @ 2013-02-22 16:09 UTC (permalink / raw)
  To: vinod.koul; +Cc: alsa-devel

This patch is now obsolete - an equivalent change has already been applied
So no rebased version.

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

end of thread, other threads:[~2013-02-22 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10  0:22 [PATCH TINYCOMPRESS 13/14] compress: Prevent divide-by-zero faults in get_hpointer() Richard Fitzgerald
2013-02-22 16:09 ` Richard Fitzgerald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).