Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7071070rwb; Tue, 6 Dec 2022 00:15:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf5zwy7kB4VDJu5T9aaALHmPC+3tcTz3u0dTfIbAfTpeu6y7cjt7qoB/sa/5YKVdDnV0hq+J X-Received: by 2002:a62:687:0:b0:56e:924e:ee22 with SMTP id 129-20020a620687000000b0056e924eee22mr68753076pfg.34.1670314555358; Tue, 06 Dec 2022 00:15:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670314555; cv=none; d=google.com; s=arc-20160816; b=u0AcYflTD5bTstVy9knTirQ+/ko1KaBlypcsq2bp/oezy2iWu2jGi8hW77dVJe8MJB UbOMQbsqT/6Gnud0OI7HyvJOPR68iJPOkOkDNrBiUOfKR0T5CXaZmgk+kR3FQjUXIpyF CTyM+pJxoIq4kCMTsCqYa9rpn3Ilcs5PkCaJzj0z7PZBYjl26VrtMXgukuCWN0Sxn6g0 +vw/ShK3fvEpQ+r35r5vr+9Q2dn0WPQL1e3PA/8mTAuzpOyItrtmjF8Mkkfpk3cPGPyK 5pKGK4ucfNcrFg/10sQBrjaN2KcArmn3KjMCe30s77Q6IRRpziHv5C45qYkMxnPS9oEL ei3w== 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 :message-id:date:subject:cc:to:from; bh=uvIwvQFPXHNWdI0QSHrSPMJV6Q1Fk4nlKOvZvGf8TBQ=; b=fjIQITswNkiBnDBpZ1b0hz7PtMExvec23ynVlvxB2ayxOtJSq6LVmFfMCsODbPAz3o Bp0luEArbTjYuQ0GZSbIixFBNRAJohmLcRbZCnJ9yUEQ84SJeVxfoVvCTWZdAVJ6jvEO tluMhn9njpD8Zjqvx8jLiL5o4sHNIe6ABIKLIdco7ZVm90+/e53Zvc4Y8JbgQrcyXC2N Np4f1N+i0tQ89kwFwNtGmxf+KlLRw5sbWXpoG/MA4DCKh8Pj3EdtZ8z80+ui0pse/QfG Dzq7Ad4HA6HTn3RlbaXQXJUsiO9CwHFGPFwaXiZCrFSuoTnfGE6x1CP7a50wk3NVtfa9 NFEg== 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 f11-20020a17090274cb00b0017840d9d42esi15840075plt.582.2022.12.06.00.15.44; Tue, 06 Dec 2022 00:15:55 -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 S231653AbiLFICw (ORCPT + 80 others); Tue, 6 Dec 2022 03:02:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231786AbiLFICt (ORCPT ); Tue, 6 Dec 2022 03:02:49 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B64ADD0; Tue, 6 Dec 2022 00:02:43 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowAC318wd945jfLA5BQ--.52774S2; Tue, 06 Dec 2022 16:02:37 +0800 (CST) From: Jiasheng Jiang To: robdclark@gmail.com, quic_abhinavk@quicinc.com, dmitry.baryshkov@linaro.org, sean@poorly.run, airlied@gmail.com, daniel@ffwll.ch, quic_jesszhan@quicinc.com, ville.syrjala@linux.intel.com, yang.lee@linux.alibaba.com Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] drm/msm/dpu: Add check for pstates Date: Tue, 6 Dec 2022 16:02:36 +0800 Message-Id: <20221206080236.43687-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowAC318wd945jfLA5BQ--.52774S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Gr1UKr18XFy8Jw4DWrW7urg_yoWDXFX_G3 W5Awn8Xr47CrWqg3W8Aw1fury0y3s09F1kXasaqa43ZFZFqrnrZ3y2v3yrJr1fuFWUtFnr Aa1xJ34rArsxGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JUqD73UUUUU= X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 As kzalloc may fail and return NULL pointer, it should be better to check pstates in order to avoid the NULL pointer dereference. Fixes: 25fdd5933e4c ("drm/msm: Add SDM845 DPU support") Signed-off-by: Jiasheng Jiang --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 13ce321283ff..f51cb46ecfd6 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -1150,6 +1150,8 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc, bool needs_dirtyfb = dpu_crtc_needs_dirtyfb(crtc_state); pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL); + if (!pstates) + return -ENOMEM; if (!crtc_state->enable || !crtc_state->active) { DRM_DEBUG_ATOMIC("crtc%d -> enable %d, active %d, skip atomic_check\n", -- 2.25.1