Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7079365rwb; Tue, 6 Dec 2022 00:26:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7PRX6EUBIpYUaDNPcFK9Tk4/B+mVc2t4K/8qVfquc7YhTXaagodYeVqmBk2W8Sot/fiLsO X-Received: by 2002:a05:6402:1593:b0:46b:fb7d:2188 with SMTP id c19-20020a056402159300b0046bfb7d2188mr18477926edv.395.1670315180780; Tue, 06 Dec 2022 00:26:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670315180; cv=none; d=google.com; s=arc-20160816; b=HaaR3fLnfTh4bMVzAVRbIyQBRy7X6iLd0VTGgILM5Rce4Xhhm9q+dhhSjaFfXTdUKR rYhuDf9jH03F5/EBDQwRb35LyuC0YfvQHJ15+cS6Yu+dZsMLstVE8K44rLTkAvHoaWMj Na8KfCiAePRRlzpeVQ2NTD5h6nAXyJkKar9hRrmorOjDL7bWp6z7dIHA3E+uL73JC3+Y bLvkniz1Ff1bQvpt96iqd+Y4f0/RxKmgdfBIt6g1RLC4VarE8S01G1MR2jlHSMXzVupp 9bJocy5RbxW+VuaY/nT6qpLNspx7fJrh/wfDDz3K9FpTXgMboh3hcWQoz/bm5Fd9U77T zucg== 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=EaPjQghf63+SXdPyDtKo33WFRi/A+ICFnB3gj16bkxw=; b=RrmpS8v5nv4/tSTa0hs9qewyoVWm8vXz23N08N6OFozHEmRmoBzZ+tye4YVoFovgHD fJHQOsF4ZgbXHibDg9K+gp3m0dHsJKPoYvfpa9At85qCIt0hTD0TLJxmHBeVl95j6HDr 7P+mkCtVtrhfVvxWaLPYIApC42Dn7Xee+0mZbceyg53MBnDKkUbg1v1g71TpzAX8kR3S m/ozwjmFBlGbhwOMqAWNeAoFBPJq0kSz5EE4IJOShJW395V0GBUeIKakAqT/NgUDYRl0 rXBAN/2opuOpe6YUjykfVKl7NyhWNqfLQOEgnjo89TwbKX3zxNCnSGWYmaPYtTrwHo/8 P8Bw== 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 u1-20020a1709064ac100b007add0c2ee2csi10618956ejt.924.2022.12.06.00.26.01; Tue, 06 Dec 2022 00:26:20 -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 S232054AbiLFIF2 (ORCPT + 79 others); Tue, 6 Dec 2022 03:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiLFIFZ (ORCPT ); Tue, 6 Dec 2022 03:05:25 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 05E1E18352; Tue, 6 Dec 2022 00:05:23 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowACnx8y+945j3c05BQ--.56942S2; Tue, 06 Dec 2022 16:05:18 +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 cstate Date: Tue, 6 Dec 2022 16:05:17 +0800 Message-Id: <20221206080517.43786-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowACnx8y+945j3c05BQ--.56942S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw4kAw4rXF45tFyDKryUWrg_yoWDuFc_WF 45Cr1DtrW7C3Wvg3Wjywn3Kr10kr9a9F48Xw4kta4fArWavrnrCwsIq3y8Gr13uF1UtFyD A3W7try3ArsxAjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JUsF4iUUUUU= 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 cstate in order to avoid the NULL pointer dereference in __drm_atomic_helper_crtc_reset. Fixes: 1cff7440a86e ("drm/msm: Convert to using __drm_atomic_helper_crtc_reset() for reset.") Signed-off-by: Jiasheng Jiang --- drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c index 13ce321283ff..22c2787b7b38 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c @@ -968,7 +968,10 @@ static void dpu_crtc_reset(struct drm_crtc *crtc) if (crtc->state) dpu_crtc_destroy_state(crtc, crtc->state); - __drm_atomic_helper_crtc_reset(crtc, &cstate->base); + if (cstate) + __drm_atomic_helper_crtc_reset(crtc, &cstate->base); + else + __drm_atomic_helper_crtc_reset(crtc, NULL); } /** -- 2.25.1