Staging: intel_sst: off by one bug
authorDan Carpenter <error27@gmail.com>
Fri, 15 Oct 2010 20:36:48 +0000 (22:36 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 15 Oct 2010 22:42:26 +0000 (15:42 -0700)
This should be >= instead of > or we go passed the end of the array.

Also the arrays are declared with size MAX_NUM_STREAMS.  This is the
only place that uses MAX_NUM_STREAMS_MFLD.  It seems like asking for
trouble to use two variables for the same information.  I've changed
everything to use MAX_NUM_STREAMS.

This bug isn't really harmful.  In the worst case, if you enabled
debugging then you would see a message.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/intel_sst/intel_sst_fw_ipc.h
drivers/staging/intel_sst/intel_sst_stream.c

index 1a2f67f..9d3c368 100644 (file)
@@ -31,7 +31,6 @@
 */
 
 #define MAX_NUM_STREAMS_MRST 3
-#define MAX_NUM_STREAMS_MFLD 6
 #define MAX_NUM_STREAMS 6
 #define MAX_DBG_RW_BYTES 80
 #define MAX_NUM_SCATTER_BUFFERS 8
index 1ce3a9c..b2c4b70 100644 (file)
@@ -45,7 +45,7 @@
  */
 int sst_check_device_type(u32 device, u32 num_chan, u32 *pcm_slot)
 {
-       if (device > MAX_NUM_STREAMS_MFLD) {
+       if (device >= MAX_NUM_STREAMS) {
                pr_debug("sst: device type invalid %d\n", device);
                return -EINVAL;
        }