Merge branch 'fix/hda' of git://github.com/tiwai/sound
[pandora-kernel.git] / drivers / misc / ti-st / st_core.c
index f91f82e..ba168a7 100644 (file)
@@ -338,6 +338,12 @@ void st_int_recv(void *disc_data,
                        /* Unknow packet? */
                default:
                        type = *ptr;
+                       if (st_gdata->list[type] == NULL) {
+                               pr_err("chip/interface misbehavior dropping"
+                                       " frame starting with 0x%02x", type);
+                               goto done;
+
+                       }
                        st_gdata->rx_skb = alloc_skb(
                                        st_gdata->list[type]->max_frame_size,
                                        GFP_ATOMIC);
@@ -354,6 +360,7 @@ void st_int_recv(void *disc_data,
                ptr++;
                count--;
        }
+done:
        spin_unlock_irqrestore(&st_gdata->lock, flags);
        pr_debug("done %s", __func__);
        return;
@@ -605,7 +612,7 @@ long st_unregister(struct st_proto_s *proto)
        pr_debug("%s: %d ", __func__, proto->chnl_id);
 
        st_kim_ref(&st_gdata, 0);
-       if (proto->chnl_id >= ST_MAX_CHANNELS) {
+       if (!st_gdata || proto->chnl_id >= ST_MAX_CHANNELS) {
                pr_err(" chnl_id %d not supported", proto->chnl_id);
                return -EPROTONOSUPPORT;
        }
@@ -717,9 +724,10 @@ static void st_tty_close(struct tty_struct *tty)
         */
        spin_lock_irqsave(&st_gdata->lock, flags);
        for (i = ST_BT; i < ST_MAX_CHANNELS; i++) {
-               if (st_gdata->list[i] != NULL)
+               if (st_gdata->is_registered[i] == true)
                        pr_err("%d not un-registered", i);
                st_gdata->list[i] = NULL;
+               st_gdata->is_registered[i] = false;
        }
        st_gdata->protos_registered = 0;
        spin_unlock_irqrestore(&st_gdata->lock, flags);