Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2144431iof; Tue, 7 Jun 2022 21:13:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTFR19w28HZEJJI5x2WbULV4xiuaWrsLOCuLoI8ZxDzRPL3PvdSXfLD9s4UM8nNmuId4rI X-Received: by 2002:a63:4e62:0:b0:398:cb40:19b0 with SMTP id o34-20020a634e62000000b00398cb4019b0mr28344097pgl.445.1654661637000; Tue, 07 Jun 2022 21:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661636; cv=none; d=google.com; s=arc-20160816; b=KvEBe/dnWn/+KBslULIUe4GoRPZRx2uxzZZnaXx5StA+HhN83LFxC/d8nYFhRUg40t fsZ4nYtYIvhNfP+DDn1vvGSzhbWKiBU9g7BSnr1J7TMknI65JF7Geg/M6nEcoxn2yrYC boVWpJ6gbUSPrmCFvecQa6fCBqIWScQw8r9hsVWLQTz1tGvL4tkrM8uOTHVnhbtu7Thh wuzuyxfnawu1TNucLvRaaRndklbYJErzkFGDena3WuvBqrRp4AVXZq/u3UXadYWu7zST eL20gyxBJsfTLNb631VLyMWTlob8GRco07hCQhBlqQg94wVsDa+hdMplTy+TDgpFImeV PwyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OilqyA4TbFBSDbLyjLFa5bIk0Jj/ij9UfGF2GzjsBT4=; b=KmJWJRxy/7mXrl3yMT353ZdBU7udvsxYkp+JYXzxT1WzqO1li2cMYFT1SiIT2uqJAF z577cTJaizbyi6c8x0liPh867J8l2+YaJAK4qWVv7FArdxq8Jw9as8osNZ35uQZm9ExT Pacue+/P2vIzaFOYIcMGw3hh2GX4lKyHZA2P4cNjek7n2sDMKvMQph4bWnyCLj1zIv/s P+VEFMcKoIHbiFZ3KMgo35IYI96H00mX9ixSQHrm8niDbY0WAgwKmgHqhhWakPRWRIU3 7B7GrG6YR4r0P7J1mxdTcAZ/NhrbwHNqktrAirI0FVw6FM4KONrTa39kLA6m1n34+crQ Eo0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qesJY5Up; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b5-20020a056a00114500b0051bf49524basi15629236pfm.284.2022.06.07.21.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:13:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qesJY5Up; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7E22241E4F5; Tue, 7 Jun 2022 20:52:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384235AbiFGWOU (ORCPT + 99 others); Tue, 7 Jun 2022 18:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379986AbiFGVLW (ORCPT ); Tue, 7 Jun 2022 17:11:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67B26131F17; Tue, 7 Jun 2022 11:52:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5A6E4B81F6D; Tue, 7 Jun 2022 18:52:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38863C385A2; Tue, 7 Jun 2022 18:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627962; bh=2u3HzTx97D8KukJGqGjYi4/l3+1TkIRnHr/uNhU+Aow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qesJY5Upl78/YcXh7FYhI20WSCEPDqagh8gvEhEoUTT0sdrRqfFaLIq0ZfvfO30si FELmgivSaC3mc8BdtTr8d9/b7HHrB+9Kw3DlD51duUTgbC2cg8vnkWcwUyDXjwoa+m qkDZpr6RCUqrdrYKr1GZUeq0NLkS3fYHgOtC/XRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Price , Liviu Dudau , Sasha Levin Subject: [PATCH 5.18 115/879] drm/plane: Move range check for format_count earlier Date: Tue, 7 Jun 2022 18:53:53 +0200 Message-Id: <20220607165006.039995895@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Price [ Upstream commit 4b674dd69701c2e22e8e7770c1706a69f3b17269 ] While the check for format_count > 64 in __drm_universal_plane_init() shouldn't be hit (it's a WARN_ON), in its current position it will then leak the plane->format_types array and fail to call drm_mode_object_unregister() leaking the modeset identifier. Move it to the start of the function to avoid allocating those resources in the first place. Signed-off-by: Steven Price Signed-off-by: Liviu Dudau Link: https://lore.kernel.org/dri-devel/20211203102815.38624-1-steven.price@arm.com/ Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_plane.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c index bf0daa8d9bbd..726f2f163c26 100644 --- a/drivers/gpu/drm/drm_plane.c +++ b/drivers/gpu/drm/drm_plane.c @@ -247,6 +247,13 @@ static int __drm_universal_plane_init(struct drm_device *dev, if (WARN_ON(config->num_total_plane >= 32)) return -EINVAL; + /* + * First driver to need more than 64 formats needs to fix this. Each + * format is encoded as a bit and the current code only supports a u64. + */ + if (WARN_ON(format_count > 64)) + return -EINVAL; + WARN_ON(drm_drv_uses_atomic_modeset(dev) && (!funcs->atomic_destroy_state || !funcs->atomic_duplicate_state)); @@ -268,13 +275,6 @@ static int __drm_universal_plane_init(struct drm_device *dev, return -ENOMEM; } - /* - * First driver to need more than 64 formats needs to fix this. Each - * format is encoded as a bit and the current code only supports a u64. - */ - if (WARN_ON(format_count > 64)) - return -EINVAL; - if (format_modifiers) { const uint64_t *temp_modifiers = format_modifiers; -- 2.35.1