From: Jaroslav Kysela <jkysela@redhat.com> Date: Mon, 22 Mar 2010 17:15:51 -0400 Subject: [sound] hda_intel: avoid divide by zero in azx devices Message-id: <201003221715.o2MHFpqI024531@int-mx08.intmail.prod.int.phx2.redhat.com> Patchwork-id: 23696 O-Subject: [RHEL 5.6 PATCH] ALSA - snd-hda-intel driver - avoid divide by zero Bugzilla: 567172 RH-Acked-by: Jarod Wilson <jarod@redhat.com> RH-Acked-by: Jerome Marchand <jmarchan@redhat.com> RH-Acked-by: Prarit Bhargava <prarit@redhat.com> Bugzilla ======== BZ#567172 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=567172 Description =========== The OSS emulation in the ALSA driver can trigger division by zero in the snd-hda-intel driver. This patch adds a simple check for this situation to the snd-hda-intel driver. This version contains WARN_ONCE-like code. Upstream Status of the patch ============================ In upstream. Signed-off-by: Jarod Wilson <jarod@redhat.com> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 0541b7c..901b5ad 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1857,6 +1857,15 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) if (!bdl_pos_adj[chip->dev_index]) return 1; /* no delayed ack */ + if (azx_dev->period_bytes == 0) { + static int once; + if (!once) + printk(KERN_WARNING + "hda-intel: Divide by zero was avoided " + "in azx_dev->period_bytes.\n"); + once = 1; + return 0; + } if (pos % azx_dev->period_bytes > azx_dev->period_bytes / 2) return 0; /* NG - it's below the period boundary */ return 1; /* OK, it's fine */