diff --git a/drivers/cam_sync/cam_sync.c b/drivers/cam_sync/cam_sync.c index 70fd07eb95..624f99c675 100644 --- a/drivers/cam_sync/cam_sync.c +++ b/drivers/cam_sync/cam_sync.c @@ -2777,6 +2777,13 @@ static int cam_sync_component_bind(struct device *dev, if (!sync_dev) return -ENOMEM; + sync_dev->sync_table = vzalloc(sizeof(struct sync_table_row) * CAM_SYNC_MAX_OBJS); + if (!sync_dev->sync_table) { + CAM_ERR(CAM_SYNC, "Mem Allocation failed for sync table"); + kfree(sync_dev); + return -ENOMEM; + } + mutex_init(&sync_dev->table_lock); spin_lock_init(&sync_dev->cam_sync_eventq_lock); @@ -2878,6 +2885,7 @@ mcinit_fail: video_unregister_device(sync_dev->vdev); video_device_release(sync_dev->vdev); vdev_fail: + vfree(sync_dev->sync_table); mutex_destroy(&sync_dev->table_lock); kfree(sync_dev); return rc; @@ -2903,6 +2911,7 @@ static void cam_sync_component_unbind(struct device *dev, for (i = 0; i < CAM_SYNC_MAX_OBJS; i++) spin_lock_init(&sync_dev->row_spinlocks[i]); + vfree(sync_dev->sync_table); kfree(sync_dev); sync_dev = NULL; } diff --git a/drivers/cam_sync/cam_sync_private.h b/drivers/cam_sync/cam_sync_private.h index 266f3e1bee..0ee54641f5 100644 --- a/drivers/cam_sync/cam_sync_private.h +++ b/drivers/cam_sync/cam_sync_private.h @@ -345,7 +345,7 @@ struct cam_signalable_info { * * @vdev : Video device * @v4l2_dev : V4L2 device - * @sync_table : Table of all sync objects + * @sync_table : Table of all sync objects allocated when driver initializes * @row_spinlocks : Spinlock array, one for each row in the table * @table_lock : Mutex used to lock the table * @open_cnt : Count of file open calls made on the sync driver @@ -360,7 +360,7 @@ struct cam_signalable_info { struct sync_device { struct video_device *vdev; struct v4l2_device v4l2_dev; - struct sync_table_row sync_table[CAM_SYNC_MAX_OBJS]; + struct sync_table_row *sync_table; spinlock_t row_spinlocks[CAM_SYNC_MAX_OBJS]; struct mutex table_lock; int open_cnt;