From nobody Mon Nov 25 18:52:09 2024 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 664211FB8BC for ; Fri, 25 Oct 2024 16:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729875427; cv=none; b=OTlAMIRC72N4OmyU2MEEAR6BshHryGCd0xFK3fRAcpWl6J0uhaUiHlpPOnXq0bNJ+AMj08WcrnFCJAXGaalmA3bUQq9+EjOl2xufSH4gwbiFAwNXV1KLkA19iJq7WUrJgr/iECDqeZfSkDpxLloZpbib3OA9Fl6+kdMHiAXX5Hw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729875427; c=relaxed/simple; bh=RveC5jacooImmHBxMnm+SqvD0OPds08xgXiCC+fcXwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eb2wtBy2KJ3ukwcc21NW2t3GFuGLZnuN3Zimqklcj0wuLugV9Qu2ckM3USGxTwo6PB7FY7r/PI4TTfgXq1kWoK3rD8YT3Iv51p7jQCVL3fK53eJSbHWKMIJbjGKsdvNRn5S76DmOsZyBDAeTUlCmwhrNOXKDHHgPSbr7GxygkMs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=dJC9tfZh; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dJC9tfZh" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7ea8de14848so1334099a12.2 for ; Fri, 25 Oct 2024 09:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729875425; x=1730480225; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8O+PQVPJ/vy+FUOPeA37d+cZZmUqt00r3pyhnqMSbPI=; b=dJC9tfZhS44WzqmnZqrGmUI34HmmcNlOYfKOhXa/vgD5xaLwbouWc0xz9+HAVMPGAm 7ybH9WQiZJdm+W9Pr9v3f6EBwPIatQKZTAIVDr7qYJ21O4uAiGzEq/BfFQbk/GoQ1jll p/Gl9uAvBAgZrEIm7kk3xU0OTXaa+xd64QY2s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729875425; x=1730480225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8O+PQVPJ/vy+FUOPeA37d+cZZmUqt00r3pyhnqMSbPI=; b=lr6PFbZgywLhznUFj7UbfGec9wpsNAvj+BnBVUOoYMSAGRdoeb+FML6JAmYAacSZC/ EK8H6zcijZJJGE/ijDhi4aZ6CMIDKVyVqGyQGsnct+hYKFTasP518oVtohn+CnJogwVP UtqlXgGOUiP2yjwOR3/RS8vjyahaCVs50Hr0egFqVJIjXO99sKlggwWm3osNdbQERP3r eoPi21oFZXu2dS52USHKAW/wNbiTI5FNqVXDdaQU0nBwalhG8BSPW8gNo07sabbCQq9y pGO/yNzo5CvFghYfJeUa1SCHWN55ZEzkmRKfChkvQKzl12RjMwflg4Y3IUhg9v3IRbNv 8/fA== X-Forwarded-Encrypted: i=1; AJvYcCWTb4+M4Q7CSiwm0oAJnLRY8xhClVHjDpJ29tkVtiZutWZyT8gFtCHercfdRMPq2KaAcYsGMSrptfqQX8Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxDtkMJdJTvVvkeOR278nhcPwllN8ZlE3wQHe8uZmra88dbAItP QIRNO+QN2HRpyXH1QstSogY6ojQeWkQLewGBbD7OIp1UHCWyytRdNzMlyJjYiw== X-Google-Smtp-Source: AGHT+IH7rfguzduKr1bcBWzJK7+v3a3TINoVQscqXJeQZUt3/8c4xIaOMv18ZR2WsqaNoVrM7t4Llw== X-Received: by 2002:a05:6a20:9f45:b0:1d9:111f:4b46 with SMTP id adf61e73a8af0-1d978b14665mr12866841637.12.1729875424739; Fri, 25 Oct 2024 09:57:04 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:bd37:bccf:f3e:a9ef]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7205791db5fsm1318970b3a.11.2024.10.25.09.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 09:57:04 -0700 (PDT) From: Sergey Senozhatsky To: Stanimir Varbanov , Vikash Garodia Cc: Dikshita Agarwal , Bryan O'Donoghue , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky , Tomasz Figa Subject: [PATCHv6 1/3] media: venus: fix enc/dec destruction order Date: Sat, 26 Oct 2024 01:56:41 +0900 Message-ID: <20241025165656.778282-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog In-Reply-To: <20241025165656.778282-1-senozhatsky@chromium.org> References: <20241025165656.778282-1-senozhatsky@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We destroy mutex-es too early as they are still taken in v4l2_fh_exit()->v4l2_event_unsubscribe()->v4l2_ctrl_find(). We should destroy mutex-es right before kfree(). Also do not vdec_ctrl_deinit() before v4l2_fh_exit(). Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files") Suggested-by: Tomasz Figa Signed-off-by: Sergey Senozhatsky Reviewed-by: Bryan O'Donoghue --- drivers/media/platform/qcom/venus/vdec.c | 7 ++++--- drivers/media/platform/qcom/venus/venc.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platf= orm/qcom/venus/vdec.c index 6252a6b3d4ba..0013c4704f03 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1752,13 +1752,14 @@ static int vdec_close(struct file *file) cancel_work_sync(&inst->delayed_process_work); v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); - vdec_ctrl_deinit(inst); ida_destroy(&inst->dpb_ids); hfi_session_destroy(inst); - mutex_destroy(&inst->lock); - mutex_destroy(&inst->ctx_q_lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); + vdec_ctrl_deinit(inst); + + mutex_destroy(&inst->lock); + mutex_destroy(&inst->ctx_q_lock); =20 vdec_pm_put(inst, false); =20 diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platf= orm/qcom/venus/venc.c index 322a7737e2c7..6a26a6592424 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1519,14 +1519,14 @@ static int venc_close(struct file *file) =20 v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); - venc_ctrl_deinit(inst); hfi_session_destroy(inst); - mutex_destroy(&inst->lock); - mutex_destroy(&inst->ctx_q_lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); + venc_ctrl_deinit(inst); =20 inst->enc_state =3D VENUS_ENC_STATE_DEINIT; + mutex_destroy(&inst->lock); + mutex_destroy(&inst->ctx_q_lock); =20 venc_pm_put(inst, false); =20 --=20 2.47.0.163.g1226f6d8fa-goog