Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5388932rwl; Sun, 8 Jan 2023 14:18:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvns/quRr4uyaq5gp3NTi0hL5hmrdIJHkSklE4Z2k6Z4MzhDLciO08IVF2AqqHosE4ypRkE X-Received: by 2002:a05:6402:d51:b0:499:8849:5fac with SMTP id ec17-20020a0564020d5100b0049988495facmr2522517edb.40.1673216301106; Sun, 08 Jan 2023 14:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673216301; cv=none; d=google.com; s=arc-20160816; b=hAFbUH7NyCG74T0FoRj0j8kx9Dasd9NEGhy5nyCoJF1KWEkTlCSjL2X/EXgP/MVWMZ 3VuVi8R9zKsBbH8Q/4r61BsTKqS38V+vp58A/KHNTO3fyCyYyce56G2LHqTDeMhqNGa/ GWE8iVj5lg4KB6RWeDQ28JnkV9Pq5NpkXdkYbeKtZR2zjPYio/JBI1QS7vIGBPzv6lFj g0a8neNgy/GHeP6riKshS8T4ii2Dnsl9irSblW9ljLL+AsXj1ygUgzQL+Xdq/sGSqIMk +hcSuEm6m7/oqX/IUU4bm2f6dV/ls6WfR/VtQp0xkbpVoCpH/8yy/5oCs1HIh3zrkY69 nbHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6e8O8V82C5N5Vb0KJCfa+OtRNISoBAeakdYZbJjo70I=; b=XCFTKFhBHImLS7bI1NziNE0+UEwZkQci9POFnibkb83y86g7ENgNNVjNyjN4G8bbl7 kZi7fWXN93+atKJBbshRp55EKe/Ca24TnOYcRk9HAUkBrvm1PKfp07gUEy39NFyrfBWn Jm9lWKNW0x/WfAFacRoSOzcGxh9LFrNYBGLfLJUuk+DDQTbBYg1y5oD54vWiEXOA3hpA vNrxUNVeWxuAuUQX/fpSi8kQBMK0P9Uu0G48YO3dP9g6VEuKtwgyoEZrR1P5Zpl2NMgp BnoKICqMJnFG9q9veIVI2ccKddO2NJ9pys2KkkRZLz7UTRWlyPhyqPFzZwQwqdjqTyM7 jH3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=raLWVm7q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h10-20020a056402280a00b00443088b40b7si9988434ede.123.2023.01.08.14.18.09; Sun, 08 Jan 2023 14:18:21 -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; dkim=pass header.i=@linaro.org header.s=google header.b=raLWVm7q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbjAHV4N (ORCPT + 51 others); Sun, 8 Jan 2023 16:56:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbjAHV4L (ORCPT ); Sun, 8 Jan 2023 16:56:11 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 169927664 for ; Sun, 8 Jan 2023 13:56:10 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id v25so10216006lfe.12 for ; Sun, 08 Jan 2023 13:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6e8O8V82C5N5Vb0KJCfa+OtRNISoBAeakdYZbJjo70I=; b=raLWVm7qNmusfNaKZbuYvMr1H/R2jjVHDWBRtsuze6qnSAFV2T75dP0NSoc0b6/5Ad RfL+3pA28APIv55CCUkBN5AGuddLKduXNZ7kmbO0e9WQYgxbtEcsjHrv2QmG8wEtJ/GT MwCsH7tUzrPPSQ6mfqxOaEkKy2+6pGKbL/CR3tYOvEoM/xZ6JgEpn7X/L3dSS8UV9y+N zIh9hwxCorIIP9WXULKAkpj9uuZF0+0bWY+kDfHvEfROOgo+Z0uC3Nl/ytWUP0YGeaw9 lkn4KykT94f5I/xRRFrJBW5qKoyNiDmXDYTxv6d1uCRmA6/tokgPPToci5a4WisrlunN +mww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6e8O8V82C5N5Vb0KJCfa+OtRNISoBAeakdYZbJjo70I=; b=nqWSTte3L6Pimo1hwqdH62cT1c85xs1k6XXn3SCiWWZOPJgXgc4LTuF1Ax42IkNrb9 vOwiZb8R+kKeC08kbpGuDnvSRAd3ali4N7xPetxibdJHZW5r1yZ/V4IT3e7MO0H9yVhj sOwDZ4xRlMQydkXYLrgyFYd8paFt2X4MlFM1pEuTe/boG/FiOBrxL3bpN9OtcDF+2rKo SkRCXRkBq6vFBqWJY1lOnWta/28D9ckTyj8YS6qxDH90WuDeregXpNZ2KywULHY9e8bM 0UNKJ4bNWmvIErOvRuEev4ScvLA5VT9YDTscauNoF+QSREmnf4530mGPiFV1Oox8Q+Si +UwQ== X-Gm-Message-State: AFqh2kq51ZQZHbWL+u7tLGbXzJrq8qkofxxfFpXXpZGI3tIWJfo5z+Jh kp4/TgHzuZspplQSe6dwG4flMA== X-Received: by 2002:ac2:482d:0:b0:4ba:555f:4799 with SMTP id 13-20020ac2482d000000b004ba555f4799mr11450200lft.16.1673214968460; Sun, 08 Jan 2023 13:56:08 -0800 (PST) Received: from ?IPV6:2001:14ba:a085:4d00::8a5? (dzccz6yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a085:4d00::8a5]) by smtp.gmail.com with ESMTPSA id c19-20020a056512075300b004b15bc0ff63sm1239096lfs.277.2023.01.08.13.56.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Jan 2023 13:56:08 -0800 (PST) Message-ID: Date: Sun, 8 Jan 2023 23:56:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] drm/msm/dpu: Add check for cstate Content-Language: en-GB To: Jiasheng Jiang , robdclark@gmail.com, quic_abhinavk@quicinc.com, 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 References: <20221206080517.43786-1-jiasheng@iscas.ac.cn> From: Dmitry Baryshkov In-Reply-To: <20221206080517.43786-1-jiasheng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 On 06/12/2022 10:05, Jiasheng Jiang wrote: > 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); NAK. The proper fix is to add the if() but to skip the else clause. We should not reset the crtc's state if memory allocation failed. > } > > /** -- With best wishes Dmitry