Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2147955rwd; Fri, 26 May 2023 02:23:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6FJYXkaEeZ1Bl0/1yXZVup/r32UYHjxl6tlZCldJakFz64wKLK/eUaKdrDQV86p1gvJXM1 X-Received: by 2002:a05:6a00:2e92:b0:63b:5c82:e21a with SMTP id fd18-20020a056a002e9200b0063b5c82e21amr2344515pfb.1.1685092996197; Fri, 26 May 2023 02:23:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685092996; cv=none; d=google.com; s=arc-20160816; b=qJYdI3+yOnU2izzd832OYen8JchTwPk+u94t3PgwD1tLoQzXmfZlm5xDFnXAFdU03e SZjP3sy/+8oniyB1d0MFYUD67VV3lJhW7AheVwU9ScA0NfB5CH5J4zHTuvGiH2mDhZs2 Le2o3fJvhfiDNCbCqH0lQLWYNGSjQSsICjNVKyrRN8aLU17rtkUJaG/+yMvPEre8OV1I 08R0lXVn94aL76v2XigC0XswOl0r7ml4PWDW9ioT2oQ/Q1gOeTjLWBlZQiKO33SaN5ol 6rPaA+i8fMRLCvOAfmiI4HOqPyTDhjP8TFy6dyNVi+yK+/Fs7RRgN7sp9cmW3c9Szc8T yTfA== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=8ECcZ8YLu3GV0/3XQIPv5xdkAKG/KqseTjUWFHT/RUM=; b=TkBc28TgkWhQJa2+LrcfRvdYkC4+OWs5/nxKc9OgDRUIWRXYXIDG7mrD9MPwZ+b64Y 2CcHFu8P7Lbi4d+H8BX3V5oI4n//ZddgMwjRjEbSHnDHX1zFtfdh6DmFkmE9ylwtTlt8 SF+S8LJr05mO/rYVyBfv+R5p3WRRMSTVtoVP/Q8J4ZMSUh9KacS2BZLFP+2xdf6SqPS1 eJ3jlVKVW34smCPxSD9gn4iAWqozOMzD+aDTJ2Op66jHy/4SNVsMl3RrV9EYO7OMNEsB JpDJs9P/LKKBoVO8AfUtlNFIe567+1ezYKbS4bGhhgLt+WDu/5gOD5H4N16zJJycq39E 83tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=V4Qf6k0k; 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=foss.st.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 191-20020a6217c8000000b00643b4daa91esi3343793pfx.331.2023.05.26.02.22.59; Fri, 26 May 2023 02:23:16 -0700 (PDT) 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=@foss.st.com header.s=selector1 header.b=V4Qf6k0k; 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=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242683AbjEZJOL (ORCPT + 99 others); Fri, 26 May 2023 05:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236801AbjEZJOJ (ORCPT ); Fri, 26 May 2023 05:14:09 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E710C135 for ; Fri, 26 May 2023 02:14:07 -0700 (PDT) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34Q8KF9t025769; Fri, 26 May 2023 11:13:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=8ECcZ8YLu3GV0/3XQIPv5xdkAKG/KqseTjUWFHT/RUM=; b=V4Qf6k0kx32/vWFJddoMA0LCr7yCwgVeW7GmWPYeXxSOhpJ0pXYke1/Q9PJZjifZ6efl QtqyeZJYz64YR8wW9LkvsHZaQhCu2a1Xup17BxULJ22Ju+zotLXwIPM5gFgS4a7lVRpI Z5aRa41CKxEBEAZXX5RgYcjiSKzlInMER3fB7dNZT6tqsqSM4SJm46rog0cF3cvSBLbm ELpF/coD4NJAKz9ZhVrc/237S/Fkj8d4vow55Z/MXaPBVLz9f+GY4cdoW1khbZGKKeaQ GI8zCW3EKYeolUHSD1ZdujsUmeDGXMVCcwXmNBYgHDHlNdzcFUDjRoZ7lBTepVPMeJL1 Og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3qt4avyfv1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 May 2023 11:13:51 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5EDCF10002A; Fri, 26 May 2023 11:13:48 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4C95F21BF59; Fri, 26 May 2023 11:13:48 +0200 (CEST) Received: from [10.48.0.148] (10.48.0.148) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Fri, 26 May 2023 11:13:47 +0200 Message-ID: <3b2d4e17-cd4e-7fcc-e870-06d1ffc2bb90@foss.st.com> Date: Fri, 26 May 2023 11:13:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH RESEND] drm/stm: ltdc: fix late dereference check To: Raphael Gallais-Pou , Yannick Fertre , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre Torgue CC: , , , , kernel test robot , Dan Carpenter References: <20230515123818.93971-1-raphael.gallais-pou@foss.st.com> Content-Language: en-US From: Philippe CORNU In-Reply-To: <20230515123818.93971-1-raphael.gallais-pou@foss.st.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.48.0.148] X-ClientProxiedBy: EQNCAS1NODE4.st.com (10.75.129.82) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-26_01,2023-05-25_03,2023-05-22_02 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 5/15/23 14:38, Raphael Gallais-Pou wrote: > In ltdc_crtc_set_crc_source(), struct drm_crtc was dereferenced in a > container_of() before the pointer check. This could cause a kernel panic. > > Fix this smatch warning: > drivers/gpu/drm/stm/ltdc.c:1124 ltdc_crtc_set_crc_source() warn: variable dereferenced before check 'crtc' (see line 1119) > > Reported-by: kernel test robot > Reported-by: Dan Carpenter > Link: https://lore.kernel.org/lkml/202212241802.zeLFZCXB-lkp@intel.com/ > Signed-off-by: Raphael Gallais-Pou > --- > drivers/gpu/drm/stm/ltdc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > index 03c6becda795..b8be4c1db423 100644 > --- a/drivers/gpu/drm/stm/ltdc.c > +++ b/drivers/gpu/drm/stm/ltdc.c > @@ -1145,7 +1145,7 @@ static void ltdc_crtc_disable_vblank(struct drm_crtc *crtc) > > static int ltdc_crtc_set_crc_source(struct drm_crtc *crtc, const char *source) > { > - struct ltdc_device *ldev = crtc_to_ltdc(crtc); > + struct ltdc_device *ldev; > int ret; > > DRM_DEBUG_DRIVER("\n"); > @@ -1153,6 +1153,8 @@ static int ltdc_crtc_set_crc_source(struct drm_crtc *crtc, const char *source) > if (!crtc) > return -ENODEV; > > + ldev = crtc_to_ltdc(crtc); > + > if (source && strcmp(source, "auto") == 0) { > ldev->crc_active = true; > ret = regmap_set_bits(ldev->regmap, LTDC_GCR, GCR_CRCEN); Hi Raphael, and many thanks for your patch. Acked-by: Philippe Cornu Philippe :-)