From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC87C5AE4A for ; Wed, 15 Nov 2023 19:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343824AbjKOT4w (ORCPT ); Wed, 15 Nov 2023 14:56:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343841AbjKOT4g (ORCPT ); Wed, 15 Nov 2023 14:56:36 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7AFE1B9 for ; Wed, 15 Nov 2023 11:56:33 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFC9AC433CC; Wed, 15 Nov 2023 19:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700078193; bh=wqXWy2jl2v3CE5SXUiBsX61V3NM891BouksDMaDpcpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrtvKJoIrIAChfPHzBJNZlaMi9tcgszA4WeIbZhqh5OT9aOTbvgn6HrbLZL97ul3T qX2n7wXtZjrDQ+tDhzXcWEP8IRxe5mwGw1Aw6Nv7FHL6UNfV7s8BN5/XqEHzsmnFF9 +wAOSRDDD8KAy6SlG4gmsLNuKdFMp7vZQiDCkM/4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johnny Liu , Mikko Perttunen , Thierry Reding , Sasha Levin Subject: [PATCH 6.1 144/379] gpu: host1x: Correct allocated size for contexts Date: Wed, 15 Nov 2023 14:23:39 -0500 Message-ID: <20231115192653.632765237@linuxfoundation.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231115192645.143643130@linuxfoundation.org> References: <20231115192645.143643130@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johnny Liu [ Upstream commit e889a311f74f4ae8bd40755a2c58d02e1c684fef ] Original implementation over allocates the memory size for the contexts list. The size of memory for the contexts list is based on the number of iommu groups specified in the device tree. Fixes: 8aa5bcb61612 ("gpu: host1x: Add context device management code") Signed-off-by: Johnny Liu Signed-off-by: Mikko Perttunen Signed-off-by: Thierry Reding Link: https://patchwork.freedesktop.org/patch/msgid/20230901115910.701518-1-cyndis@kapsi.fi Signed-off-by: Sasha Levin --- drivers/gpu/host1x/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/context.c b/drivers/gpu/host1x/context.c index 047696432eb21..93c0c532fe5af 100644 --- a/drivers/gpu/host1x/context.c +++ b/drivers/gpu/host1x/context.c @@ -34,10 +34,10 @@ int host1x_memory_context_list_init(struct host1x *host1x) if (err < 0) return 0; - cdl->devs = kcalloc(err, sizeof(*cdl->devs), GFP_KERNEL); + cdl->len = err / 4; + cdl->devs = kcalloc(cdl->len, sizeof(*cdl->devs), GFP_KERNEL); if (!cdl->devs) return -ENOMEM; - cdl->len = err / 4; for (i = 0; i < cdl->len; i++) { struct iommu_fwspec *fwspec; -- 2.42.0