From patchwork Fri Jun 28 14:55:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 13716285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B16AC2BD09 for ; Fri, 28 Jun 2024 14:55:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9996110E063; Fri, 28 Jun 2024 14:55:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="xrPCgdKE"; dkim-atps=neutral Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1598410E2FD for ; Fri, 28 Jun 2024 14:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1719586538; bh=7dw9vGxAvDIh5EPnuWIl/ONL4wxadRDybkCVAC6MN2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xrPCgdKENjaBvnzGXXHckLNuvHev8PfFhyPYxYWxEqH2onzUcwzhuY5SLRn/3Kbl7 AkJL/RyKyrm78p46WEDKCzF3PoP7xD8Goq2K1D//RgGD8fDaYhiwb87X9l3MkaqG3x Obxg7neR0HqPqCYLM40o+OZ55201Qi7wTswv1UNfz4edPGymWSFsUaT/lF5oXtt/Bo jgsuZIn/Pr6UoyGoDKd7qFYB5zDJP2hDIAFNgO+BNlhi/+OKVALMdG78adhhzuVdrZ eN3jxhLKNrYB7JVhCqEfNAy1LGq2xEeRI2uFGPGZo3TV4eL1e/XcDZpt8gOXKKKEde cn3NdXd3BNZvA== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 6779F37821FA; Fri, 28 Jun 2024 14:55:38 +0000 (UTC) From: Boris Brezillon To: Boris Brezillon , Steven Price , Liviu Dudau , =?utf-8?q?Adri=C3=A1n_Larumbe?= Cc: dri-devel@lists.freedesktop.org, kernel@collabora.com Subject: [PATCH 1/2] drm/panthor: Don't check the array stride on empty uobj arrays Date: Fri, 28 Jun 2024 16:55:35 +0200 Message-ID: <20240628145536.778349-2-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240628145536.778349-1-boris.brezillon@collabora.com> References: <20240628145536.778349-1-boris.brezillon@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The user is likely to leave all the drm_panthor_obj_array fields to zero when the array is empty, which will cause an EINVAL failure. Fixes: 4bdca1150792 ("drm/panthor: Add the driver frontend block") Signed-off-by: Boris Brezillon Reviewed-by: Liviu Dudau Reviewed-by: Steven Price --- drivers/gpu/drm/panthor/panthor_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index b8a84f26b3ef..b5e7b919f241 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -86,15 +86,15 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride, int ret = 0; void *out_alloc; + if (!in->count) + return NULL; + /* User stride must be at least the minimum object size, otherwise it might * lack useful information. */ if (in->stride < min_stride) return ERR_PTR(-EINVAL); - if (!in->count) - return NULL; - out_alloc = kvmalloc_array(in->count, obj_size, GFP_KERNEL); if (!out_alloc) return ERR_PTR(-ENOMEM);