[ALSA] Dereference after free in snd_hwdep_release()
[pandora-kernel.git] / sound / core / pcm_compat.c
index 4b6307d..2b53979 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <linux/compat.h>
 
-static int snd_pcm_ioctl_delay_compat(snd_pcm_substream_t *substream,
+static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
                                      s32 __user *src)
 {
        snd_pcm_sframes_t delay;
@@ -39,7 +39,7 @@ static int snd_pcm_ioctl_delay_compat(snd_pcm_substream_t *substream,
        return err;
 }
 
-static int snd_pcm_ioctl_rewind_compat(snd_pcm_substream_t *substream,
+static int snd_pcm_ioctl_rewind_compat(struct snd_pcm_substream *substream,
                                       u32 __user *src)
 {
        snd_pcm_uframes_t frames;
@@ -56,7 +56,7 @@ static int snd_pcm_ioctl_rewind_compat(snd_pcm_substream_t *substream,
        return err < 0 ? err : 0;
 }
 
-static int snd_pcm_ioctl_forward_compat(snd_pcm_substream_t *substream,
+static int snd_pcm_ioctl_forward_compat(struct snd_pcm_substream *substream,
                                       u32 __user *src)
 {
        snd_pcm_uframes_t frames;
@@ -73,12 +73,12 @@ static int snd_pcm_ioctl_forward_compat(snd_pcm_substream_t *substream,
        return err < 0 ? err : 0;
 }
 
-struct sndrv_pcm_hw_params32 {
+struct snd_pcm_hw_params32 {
        u32 flags;
-       struct sndrv_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; /* this must be identical */
-       struct sndrv_mask mres[5];      /* reserved masks */
-       struct sndrv_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
-       struct sndrv_interval ires[9];  /* reserved intervals */
+       struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; /* this must be identical */
+       struct snd_mask mres[5];        /* reserved masks */
+       struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
+       struct snd_interval ires[9];    /* reserved intervals */
        u32 rmask;
        u32 cmask;
        u32 info;
@@ -89,7 +89,7 @@ struct sndrv_pcm_hw_params32 {
        unsigned char reserved[64];
 };
 
-struct sndrv_pcm_sw_params32 {
+struct snd_pcm_sw_params32 {
        s32 tstamp_mode;
        u32 period_step;
        u32 sleep_min;
@@ -104,7 +104,7 @@ struct sndrv_pcm_sw_params32 {
 };
 
 /* recalcuate the boundary within 32bit */
-static snd_pcm_uframes_t recalculate_boundary(snd_pcm_runtime_t *runtime)
+static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime)
 {
        snd_pcm_uframes_t boundary;
 
@@ -116,10 +116,10 @@ static snd_pcm_uframes_t recalculate_boundary(snd_pcm_runtime_t *runtime)
        return boundary;
 }
 
-static int snd_pcm_ioctl_sw_params_compat(snd_pcm_substream_t *substream,
-                                         struct sndrv_pcm_sw_params32 __user *src)
+static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream,
+                                         struct snd_pcm_sw_params32 __user *src)
 {
-       snd_pcm_sw_params_t params;
+       struct snd_pcm_sw_params params;
        snd_pcm_uframes_t boundary;
        int err;
 
@@ -149,17 +149,17 @@ static int snd_pcm_ioctl_sw_params_compat(snd_pcm_substream_t *substream,
        return err;
 }
 
-struct sndrv_pcm_channel_info32 {
+struct snd_pcm_channel_info32 {
        u32 channel;
        u32 offset;
        u32 first;
        u32 step;
 };
 
-static int snd_pcm_ioctl_channel_info_compat(snd_pcm_substream_t *substream,
-                                            struct sndrv_pcm_channel_info32 __user *src)
+static int snd_pcm_ioctl_channel_info_compat(struct snd_pcm_substream *substream,
+                                            struct snd_pcm_channel_info32 __user *src)
 {
-       snd_pcm_channel_info_t info;
+       struct snd_pcm_channel_info info;
        int err;
 
        if (get_user(info.channel, &src->channel) ||
@@ -178,7 +178,7 @@ static int snd_pcm_ioctl_channel_info_compat(snd_pcm_substream_t *substream,
        return err;
 }
 
-struct sndrv_pcm_status32 {
+struct snd_pcm_status32 {
        s32 state;
        struct compat_timespec trigger_tstamp;
        struct compat_timespec tstamp;
@@ -193,10 +193,10 @@ struct sndrv_pcm_status32 {
 } __attribute__((packed));
 
 
-static int snd_pcm_status_user_compat(snd_pcm_substream_t *substream,
-                                     struct sndrv_pcm_status32 __user *src)
+static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
+                                     struct snd_pcm_status32 __user *src)
 {
-       snd_pcm_status_t status;
+       struct snd_pcm_status status;
        int err;
 
        err = snd_pcm_status(substream, &status);
@@ -221,12 +221,12 @@ static int snd_pcm_status_user_compat(snd_pcm_substream_t *substream,
 }
 
 /* both for HW_PARAMS and HW_REFINE */
-static int snd_pcm_ioctl_hw_params_compat(snd_pcm_substream_t *substream,
+static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,
                                          int refine, 
-                                         struct sndrv_pcm_hw_params32 __user *data32)
+                                         struct snd_pcm_hw_params32 __user *data32)
 {
-       struct sndrv_pcm_hw_params *data;
-       snd_pcm_runtime_t *runtime;
+       struct snd_pcm_hw_params *data;
+       struct snd_pcm_runtime *runtime;
        int err;
 
        if (! (runtime = substream->runtime))
@@ -265,14 +265,14 @@ static int snd_pcm_ioctl_hw_params_compat(snd_pcm_substream_t *substream,
 
 /*
  */
-struct sndrv_xferi32 {
+struct snd_xferi32 {
        s32 result;
        u32 buf;
        u32 frames;
 };
 
-static int snd_pcm_ioctl_xferi_compat(snd_pcm_substream_t *substream,
-                                     int dir, struct sndrv_xferi32 __user *data32)
+static int snd_pcm_ioctl_xferi_compat(struct snd_pcm_substream *substream,
+                                     int dir, struct snd_xferi32 __user *data32)
 {
        compat_caddr_t buf;
        u32 frames;
@@ -303,7 +303,7 @@ static int snd_pcm_ioctl_xferi_compat(snd_pcm_substream_t *substream,
 
 
 /* snd_xfern needs remapping of bufs */
-struct sndrv_xfern32 {
+struct snd_xfern32 {
        s32 result;
        u32 bufs;  /* this is void **; */
        u32 frames;
@@ -315,8 +315,8 @@ struct sndrv_xfern32 {
  * handler there expands again the same 128 pointers on stack, so it is better
  * to handle the function (calling pcm_readv/writev) directly in this handler.
  */
-static int snd_pcm_ioctl_xfern_compat(snd_pcm_substream_t *substream,
-                                     int dir, struct sndrv_xfern32 __user *data32)
+static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
+                                     int dir, struct snd_xfern32 __user *data32)
 {
        compat_caddr_t buf;
        compat_caddr_t __user *bufptr;
@@ -360,7 +360,7 @@ static int snd_pcm_ioctl_xfern_compat(snd_pcm_substream_t *substream,
 }
 
 
-struct sndrv_pcm_mmap_status32 {
+struct snd_pcm_mmap_status32 {
        s32 state;
        s32 pad1;
        u32 hw_ptr;
@@ -368,32 +368,32 @@ struct sndrv_pcm_mmap_status32 {
        s32 suspended_state;
 } __attribute__((packed));
 
-struct sndrv_pcm_mmap_control32 {
+struct snd_pcm_mmap_control32 {
        u32 appl_ptr;
        u32 avail_min;
 };
 
-struct sndrv_pcm_sync_ptr32 {
+struct snd_pcm_sync_ptr32 {
        u32 flags;
        union {
-               struct sndrv_pcm_mmap_status32 status;
+               struct snd_pcm_mmap_status32 status;
                unsigned char reserved[64];
        } s;
        union {
-               struct sndrv_pcm_mmap_control32 control;
+               struct snd_pcm_mmap_control32 control;
                unsigned char reserved[64];
        } c;
 } __attribute__((packed));
 
-static int snd_pcm_ioctl_sync_ptr_compat(snd_pcm_substream_t *substream,
-                                        struct sndrv_pcm_sync_ptr32 __user *src)
+static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
+                                        struct snd_pcm_sync_ptr32 __user *src)
 {
-       snd_pcm_runtime_t *runtime = substream->runtime;
-       volatile struct sndrv_pcm_mmap_status *status;
-       volatile struct sndrv_pcm_mmap_control *control;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       volatile struct snd_pcm_mmap_status *status;
+       volatile struct snd_pcm_mmap_control *control;
        u32 sflags;
-       struct sndrv_pcm_mmap_control scontrol;
-       struct sndrv_pcm_mmap_status sstatus;
+       struct snd_pcm_mmap_control scontrol;
+       struct snd_pcm_mmap_status sstatus;
        snd_pcm_uframes_t boundary;
        int err;
 
@@ -444,26 +444,26 @@ static int snd_pcm_ioctl_sync_ptr_compat(snd_pcm_substream_t *substream,
 /*
  */
 enum {
-       SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct sndrv_pcm_hw_params32),
-       SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct sndrv_pcm_hw_params32),
-       SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct sndrv_pcm_sw_params32),
-       SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct sndrv_pcm_status32),
+       SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct snd_pcm_hw_params32),
+       SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct snd_pcm_hw_params32),
+       SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct snd_pcm_sw_params32),
+       SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct snd_pcm_status32),
        SNDRV_PCM_IOCTL_DELAY32 = _IOR('A', 0x21, s32),
-       SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct sndrv_pcm_channel_info32),
+       SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct snd_pcm_channel_info32),
        SNDRV_PCM_IOCTL_REWIND32 = _IOW('A', 0x46, u32),
        SNDRV_PCM_IOCTL_FORWARD32 = _IOW('A', 0x49, u32),
-       SNDRV_PCM_IOCTL_WRITEI_FRAMES32 = _IOW('A', 0x50, struct sndrv_xferi32),
-       SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct sndrv_xferi32),
-       SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct sndrv_xfern32),
-       SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct sndrv_xfern32),
-       SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct sndrv_pcm_sync_ptr32),
+       SNDRV_PCM_IOCTL_WRITEI_FRAMES32 = _IOW('A', 0x50, struct snd_xferi32),
+       SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct snd_xferi32),
+       SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32),
+       SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32),
+       SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
 
 };
 
 static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
 {
-       snd_pcm_file_t *pcm_file;
-       snd_pcm_substream_t *substream;
+       struct snd_pcm_file *pcm_file;
+       struct snd_pcm_substream *substream;
        void __user *argp = compat_ptr(arg);
 
        pcm_file = file->private_data;
@@ -478,7 +478,7 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
         * mmap of PCM status/control records because of the size
         * incompatibility.
         */
-       substream->no_mmap_ctrl = 1;
+       pcm_file->no_compat_mmap = 1;
 
        switch (cmd) {
        case SNDRV_PCM_IOCTL_PVERSION:
@@ -497,9 +497,9 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
        case SNDRV_PCM_IOCTL_LINK:
        case SNDRV_PCM_IOCTL_UNLINK:
                if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-                       return snd_pcm_playback_ioctl1(substream, cmd, argp);
+                       return snd_pcm_playback_ioctl1(file, substream, cmd, argp);
                else
-                       return snd_pcm_capture_ioctl1(substream, cmd, argp);
+                       return snd_pcm_capture_ioctl1(file, substream, cmd, argp);
        case SNDRV_PCM_IOCTL_HW_REFINE32:
                return snd_pcm_ioctl_hw_params_compat(substream, 1, argp);
        case SNDRV_PCM_IOCTL_HW_PARAMS32: