From 2b43f489a35cb2fe59f76886002226b37a29ae06 Mon Sep 17 00:00:00 2001 From: VijayaKumar T M Date: Tue, 7 May 2019 15:12:53 +0530 Subject: [PATCH] msm: camera: jpegdma: Added missing lock for dqbuf and streamon Added missing lock to avoid race conditon for dqbuf and streamon CRs-Fixed: 2376566 Change-Id: I1c0ef9014914a9892c4d443600618c52d0aeebfa Signed-off-by: VijayaKumar T M --- .../msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c index 3bd26da23176..10f4e7196ed0 100644 --- a/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c +++ b/drivers/media/platform/msm/camera_v2/jpeg_dma/msm_jpeg_dma_dev.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2017, 2019 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -895,8 +895,12 @@ static int msm_jpegdma_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) { struct jpegdma_ctx *ctx = msm_jpegdma_ctx_from_fh(fh); + int ret; - return v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); + mutex_lock(&ctx->lock); + ret = v4l2_m2m_dqbuf(file, ctx->m2m_ctx, buf); + mutex_unlock(&ctx->lock); + return ret; } /* @@ -911,13 +915,15 @@ static int msm_jpegdma_streamon(struct file *file, struct jpegdma_ctx *ctx = msm_jpegdma_ctx_from_fh(fh); int ret; - if (!msm_jpegdma_config_ok(ctx)) + mutex_lock(&ctx->lock); + if (!msm_jpegdma_config_ok(ctx)) { + mutex_unlock(&ctx->lock); return -EINVAL; - + } ret = v4l2_m2m_streamon(file, ctx->m2m_ctx, buf_type); if (ret < 0) dev_err(ctx->jdma_device->dev, "Stream on fail\n"); - + mutex_unlock(&ctx->lock); return ret; }