staging: ti dspbridge: avoid possible NULL dereference panic
authorErnesto Ramos <ernesto@ti.com>
Wed, 28 Jul 2010 16:50:36 +0000 (11:50 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 3 Aug 2010 00:11:00 +0000 (17:11 -0700)
When dsp_notifications array is received from user,
dspbridge verifies the array has valid pointers
and dsp_notification structures. However, these
structures contain pointers that need to be
checked for valid handles.

Signed-off-by: Ernesto Ramos <ernesto@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/tidspbridge/pmgr/dspapi.c

index 1b0ab4ab1921c4c9ea5ebe023ce823c0f3df1430..da08dfc6459399e58c335d0ad9d53c883ed187ba 100644 (file)
@@ -539,7 +539,7 @@ func_end:
  */
 u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt)
 {
-       int status = 0, real_status = 0;
+       int status = 0;
        struct dsp_notification *anotifications[MAX_EVENTS];
        struct dsp_notification notifications[MAX_EVENTS];
        u32 index, i;
@@ -554,19 +554,21 @@ u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt)
        /* get the events */
        for (i = 0; i < count; i++) {
                CP_FM_USR(&notifications[i], anotifications[i], status, 1);
-               if (!status) {
-                       /* set the array of pointers to kernel structures */
-                       anotifications[i] = &notifications[i];
+               if (status || !notifications[i].handle) {
+                       status = -EINVAL;
+                       break;
                }
+               /* set the array of pointers to kernel structures */
+               anotifications[i] = &notifications[i];
        }
        if (!status) {
-               real_status = mgr_wait_for_bridge_events(anotifications, count,
+               status = mgr_wait_for_bridge_events(anotifications, count,
                                                         &index,
                                                         args->args_mgr_wait.
                                                         utimeout);
        }
        CP_TO_USR(args->args_mgr_wait.pu_index, &index, status, 1);
-       return real_status;
+       return status;
 }
 
 /*
This page took 0.026599 seconds and 5 git commands to generate.