From patchwork Sat Apr 26 06:15:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 885200 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEA00211C; Sat, 26 Apr 2025 06:15:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745648132; cv=none; b=ts8S4XtDbxSeDYbm6TOoLIkFNmPZ1YWJlSmsv7l53oU6APE0VswnQRxXS9/6ZymQ2yQosA5DqRbIZgjE6JizDDE+a3k7EZa7GIKtwD9EEFprD681s+ZnF7JvP7Ww9pn4ajb7ydVUJYdTw3fcjneCXROwgsQFf6/8gZZOiApa/hA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745648132; c=relaxed/simple; bh=mxCUaaqj8mwcZsewtRcy5pF5fmWFDs+r5MaxX0wTrqc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=g++8uhXMpKmYBKrPmdEy2uQLWWbwce4LDXdSEPAHRSqaYJ2D/zB8x2LELQNmRwcb2f28gt9cBYkKbPVR/Y6ObFttFdCMkN1tbu8D9coJEpjPvAIrKaTLRxTcJz6WTZkcFLhgL4zUu3RnD1gvdyJ1nQJBptCwhq7I6axDuui78pM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kkFI1IrL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kkFI1IrL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A9BBC4CEE2; Sat, 26 Apr 2025 06:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745648131; bh=mxCUaaqj8mwcZsewtRcy5pF5fmWFDs+r5MaxX0wTrqc=; h=From:To:Cc:Subject:Date:From; b=kkFI1IrLTK0aACJ7gZ/yLEFFfaa+kNZAVkalayMKjTEutDzdEFjbKfOc6k11cF3YO f9D7W+VHPCZxh6zbj8Q00oAWB25M6c5DduTy4gaf97L3DYscuoR2dLwVnGlpYZj/xb Vpkf3a/gAOrHb9Y7ilOiAAq3D4KZ03gtZBY2p9+UlPifeafFCbDLWvz9zn2ijdw9yK 9SaALKojSTRb9Vun73p+fZOB0nKh6k8g13K9bcfZkiIJ3OpsQNLqu1xRwMvAR1+ugy 1zH1hTQHEoQuic1L4ns51BmidwYAN6YY18/k8gnHLn3JntxRqti3dBERrrcw0WRrWY jH4uWwuZltRcA== From: Kees Cook To: Vikash Garodia Cc: Kees Cook , Dikshita Agarwal , Abhinav Kumar , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] media: iris: Cast iris_hfi_gen2_get_instance() allocation type Date: Fri, 25 Apr 2025 23:15:27 -0700 Message-Id: <20250426061526.work.106-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1624; i=kees@kernel.org; h=from:subject:message-id; bh=mxCUaaqj8mwcZsewtRcy5pF5fmWFDs+r5MaxX0wTrqc=; b=owGbwMvMwCVmps19z/KJym7G02pJDBk8lf8/L1zdfnqr/7SgAl+WQ4e2Ploz1zio/0rkxk4e2 wNL70/I6ChlYRDjYpAVU2QJsnOPc/F42x7uPlcRZg4rE8gQBi5OAZjIz5+MDDdOF5+KsT/2Obd6 8yX53/pB0m4rmiZulxKdO61pa9HNDQUMv9mPme83m7covjxsRss16Yuz56Uy/d6mlfbx2/mAA3K SEzgB X-Developer-Key: i=kees@kernel.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 In preparation for making the kmalloc family of allocators type aware, we need to make sure that the returned type from the allocation matches the type of the variable being assigned. (Before, the allocator would always return "void *", which can be implicitly cast to any pointer type.) The assigned type is "struct iris_inst *", but the returned type is "struct iris_inst_hfi_gen2 *". The allocation is intentionally larger as the first member of struct iris_inst_hfi_gen2 is struct iris_inst, so this is by design. Cast the allocation type to match the assignment. Signed-off-by: Kees Cook --- Cc: Vikash Garodia Cc: Dikshita Agarwal Cc: Abhinav Kumar Cc: Mauro Carvalho Chehab Cc: Cc: --- drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c index a908b41e2868..351820deb893 100644 --- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c @@ -953,5 +953,5 @@ void iris_hfi_gen2_command_ops_init(struct iris_core *core) struct iris_inst *iris_hfi_gen2_get_instance(void) { - return kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL); + return (struct iris_inst *)kzalloc(sizeof(struct iris_inst_hfi_gen2), GFP_KERNEL); }