Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2404275rwl; Thu, 13 Apr 2023 06:09:35 -0700 (PDT) X-Google-Smtp-Source: AKy350aB/0jwU8V79dEODfbjDZuXuAlkrNA149QP9sat0o95A9CLfExA9YsJe+x0xn84M2JMvLFG X-Received: by 2002:a05:6602:1853:b0:74c:c47e:e338 with SMTP id d19-20020a056602185300b0074cc47ee338mr1251504ioi.1.1681391375354; Thu, 13 Apr 2023 06:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681391375; cv=none; d=google.com; s=arc-20160816; b=sFk9NtJuZSYLwsybdStBtvhAhX44jIHi20X3AmA4EYsjxTGCjsRFjdf59dm2o3KReM MwFBjfr5QQTz9nw/EOcYO6wvrwBlVehb5qjXmKK+s2ONXk/+6ZlWK3elfpTbHachM12W RSXELIFZU7G39c36UJ2V9n6vK1QMA+GNj6mfEIGuno2ayRXt4Tgrtf/bqRY4un1+N+7Z exzgcsjsmso+W8Uh9Gvd1UEnHBlnqAd5pOgiGJ5PhGhtE/VzcJJiX9AcNDkPFoKrbfr8 xFYFsUbD2o+2Xs3+pIcdYLs8XwzADW8jURMoBYANC1P2YlPj7XJCEcpomv3hLhUg4w4i lHmg== 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=fV8X/jR840R+J8jRG+/wDOQExdy42LB4fTNQAvYUlkA=; b=RjtX1JHPStT6gEfcE4w9ygKfQTYmyEJDSFp/UpbKWTAhzuSx0E4n0pIu+givXfe/DR +BubRU+UIX3qZRMLtzZlJDgRvopINbPiqtwPYVYxZfqfuMouKx/NaKsDUOnJesHbiSiz H7+fgI2UhkULKQSvyUDa5Be9DUqq7+sNvE3r/6pGrT1V4KDoObt3uhM1A/Y6ohUQ8wAO GBykOZD7ndtUNe4aVgVZy9oZZOt7V3coWc3hwzAhCn2r8aScwrDOMGHvCQUohdFNmcBI qJoo/FJ9BqHHfFdTQUhBFbTvNFLmrsr/tLRrn41Utrgw/hqkcUQPBKc7TdQ6mCJ9qEwI y68w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=paB8uU8o; 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 m41-20020a05663840a900b004065fbbedf9si1959886jam.145.2023.04.13.06.09.13; Thu, 13 Apr 2023 06:09:35 -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=paB8uU8o; 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 S229871AbjDMNGP (ORCPT + 99 others); Thu, 13 Apr 2023 09:06:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbjDMNGO (ORCPT ); Thu, 13 Apr 2023 09:06:14 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D809744 for ; Thu, 13 Apr 2023 06:06:03 -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 33D9R7j0016008; Thu, 13 Apr 2023 15:05:05 +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=fV8X/jR840R+J8jRG+/wDOQExdy42LB4fTNQAvYUlkA=; b=paB8uU8oahuqvLfLu5n6ygwrZegvxs4PYDxEKLDQwhECPRUlH9WUP6qhW5DFgaV3IsOY 5d2o9U/x58IQSIeKL6z9UlKVC4+1n7bwOQLWOtlWq4S3eKmFlQrbaxXyrKNsJpzu//Xn BHIs1HfJl+cnZmUHmwiT4wOK7x9nUk67hYYQ4ucTIcEDiG34vckcgkp6/hYQk8jR7NPJ lgfFNJtP4rOmd8o+CiaqGGPDLpJtPQyFXtr8TLshSY4myBw2kyHNsTlpwe67qs5ixDgb +8/RYnxc2QXwohJAXz8ZudcWpfCN9lZufFRmGUAvkDxwlNA/TjopuL9gRPX5gwkm4xmM HQ== 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 3pxf2q9g1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Apr 2023 15:05:05 +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 46D1010002A; Thu, 13 Apr 2023 15:05:04 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 32D3D21B515; Thu, 13 Apr 2023 15:05:04 +0200 (CEST) Received: from [10.252.20.144] (10.252.20.144) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 13 Apr 2023 15:05:03 +0200 Message-ID: <31659e74-661b-8bd3-e64e-33ac6d24f577@foss.st.com> Date: Thu, 13 Apr 2023 15:04:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] drm/stm: ltdc: fix late dereference check To: Raphael GALLAIS-POU , Raphael Gallais-Pou , Philippe Cornu , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre Torgue CC: , , , , kernel test robot , Dan Carpenter References: <20230412092553.279185-1-raphael.gallais-pou@foss.st.com> Content-Language: en-US From: Yannick FERTRE In-Reply-To: <20230412092553.279185-1-raphael.gallais-pou@foss.st.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.252.20.144] X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-13_08,2023-04-13_01,2023-02-09_01 X-Spam-Status: No, score=-3.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,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 Hi Raphael, thanks for the patch. Reviewed-by: Yannick Fertre On 4/12/23 11:25, Raphael GALLAIS-POU wrote: > Attention: Sender not authenticated > -------------------------------------------------- > > 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); > -- > 2.25.1 >