Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5896532rwl; Mon, 9 Jan 2023 01:03:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvbktOK4NTTtpkZtyMtrVgNrUjg5cNcIX/2zlOqBt+ETGPK4gAU++UqmaFCd/HyzBtITUgz X-Received: by 2002:a17:906:4704:b0:7c1:ac8:73a0 with SMTP id y4-20020a170906470400b007c10ac873a0mr56894444ejq.51.1673255011754; Mon, 09 Jan 2023 01:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673255011; cv=none; d=google.com; s=arc-20160816; b=EnDr2tiZ3CCMc4GeFn75UAcP5X/2V0cCTBoxV+NFbJbnbAhsW460SnhEmXQArm2G/T 2wIOIhGSp6Eqq9dGGWKr1dKrjwvBPfEi09A4Kegh3ABTPjABcVy3rdbSsZVgySfPW2+e jsJZMW7iSV/LgEPSSqnFgMVl0T33TNLtg4iIcXMtxvMYGQc4X7+L8oymjHR3lyxTG/j3 Yff25UgmH6PAadhS9oaLEv/Kf7X5haHWehLaOfmDboQR8EUYgkks4e2+992KVFHpRTzh hovc1O9RmN9Lz8jsTMQeuDqVGAr8EZl15SqI0gepF/2NwoqO0ss75j5yFDu0SnS9v/gu jWUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=N0a5tXCrRmZVBjSj7qMqeG8xifb0wM+woVr/onV0PVw=; b=Htg+AMnngttTWf2bMt4OuH5fAf4XXTFG4DdrHiL7zybTRsLsHSHgRNTsPgjzQDP4IA Kih0sAyj37Dx3zgRKQx5Ey+Rib+lty9Ered5ypQseSwp4U+uKzOhgq34UUppx1SCR6hW PuXYA5r/X8r0LvHu9bEF1LRKIF/pGtk2IFd5T80pOyePgQW3aYO9LzQFBCGqtTINCpa0 T+Mo/0mjTxURvkRerMC4TSasU7SvUByoMLuBVNmnnV2gUV0KTMaWahZ+6oL5G79Mn8Vc 2jzygTVAoHCxzTEdRrWoE1CQKnCE45DBoUAn2XDxZd8/FutMAssd/ioiwD5RC5kLPDcG LM4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc41-20020a17090716a900b00840f80a0b03si8206654ejc.118.2023.01.09.01.03.19; Mon, 09 Jan 2023 01:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbjAIIYw (ORCPT + 54 others); Mon, 9 Jan 2023 03:24:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236534AbjAIIYF (ORCPT ); Mon, 9 Jan 2023 03:24:05 -0500 Received: from relay08.th.seeweb.it (relay08.th.seeweb.it [5.144.164.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 859516557 for ; Mon, 9 Jan 2023 00:24:03 -0800 (PST) Received: from SoMainline.org (unknown [89.205.227.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by m-r2.th.seeweb.it (Postfix) with ESMTPSA id BA0103EE8C; Mon, 9 Jan 2023 09:23:59 +0100 (CET) Date: Mon, 9 Jan 2023 09:23:57 +0100 From: Marijn Suijten To: Dmitry Baryshkov Cc: phone-devel@vger.kernel.org, Rob Clark , Abhinav Kumar , Vinod Koul , ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Sean Paul , David Airlie , Daniel Vetter , Stephen Boyd , Bjorn Andersson , Jessica Zhang , Ville =?utf-8?B?U3lyasOkbMOk?= , Kuogee Hsieh , Jani Nikula , sunliming , Sam Ravnborg , Haowen Bai , Konrad Dybcio , Loic Poulain , Vinod Polimera , Douglas Anderson , Vladimir Lypak , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Drew Davenport Subject: Re: [PATCH v2 4/8] drm/msm/dpu: Disallow unallocated resources to be returned Message-ID: <20230109082357.meebk7udokdfvwle@SoMainline.org> References: <20221221231943.1961117-1-marijn.suijten@somainline.org> <20221221231943.1961117-5-marijn.suijten@somainline.org> <1b872a47-6ffc-1fe9-f283-897dbc37d709@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1b872a47-6ffc-1fe9-f283-897dbc37d709@linaro.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On 2023-01-09 01:30:29, Dmitry Baryshkov wrote: > On 09/01/2023 01:28, Dmitry Baryshkov wrote: > > On 22/12/2022 01:19, Marijn Suijten wrote: > >> In the event that the topology requests resources that have not been > >> created by the system (because they are typically not represented in > >> dpu_mdss_cfg ^1), the resource(s) in global_state (in this case DSC > >> blocks) remain NULL but will still be returned out of > >> dpu_rm_get_assigned_resources, where the caller expects to get an array > >> containing num_blks valid pointers (but instead gets these NULLs). > >> > >> To prevent this from happening, where null-pointer dereferences > >> typically result in a hard-to-debug platform lockup, num_blks shouldn't > >> increase past NULL blocks and will print an error and break instead. > >> After all, max_blks represents the static size of the maximum number of > >> blocks whereas the actual amount varies per platform. > >> > >> ^1: which can happen after a git rebase ended up moving additions to > >> _dpu_cfg to a different struct which has the same patch context. > >> > >> Fixes: bb00a452d6f7 ("drm/msm/dpu: Refactor resource manager") > >> Signed-off-by: Marijn Suijten > >> --- > >> ? drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 5 +++++ > >> ? 1 file changed, 5 insertions(+) > > > > I think the patch is not fully correct. Please check resource > > availability during allocation. I wouldn't expect an error from > > get_assigned_resources because of resource exhaustion. Theoretically patch 5/8 should take care of this, and we should never reach this failure condition. Emphasis on /should/, this may happen again if/when another block type is added with sub-par resource allocation and assignment implementation. > Another option, since allocation functions (except DSC) already have > these safety checks: check error message to mention internal > inconstency: allocated resource doesn't exist. Is this a suggestion for the wording of the error message? - Marijn