Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2295004rwd; Fri, 26 May 2023 04:50:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6B+rz3w3xgX62h+vTYfuMOw+RPCw73KhhCmvB1r9PJnl0M6f78YQGifqtMdSVnkAXPnNtY X-Received: by 2002:a05:6a21:6d90:b0:10e:786c:820d with SMTP id wl16-20020a056a216d9000b0010e786c820dmr2032180pzb.32.1685101822692; Fri, 26 May 2023 04:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685101822; cv=none; d=google.com; s=arc-20160816; b=chBMtJhdx18cO1tIo+U7ySR44S0QYWTnDt/thFhSJNQlOxN2VRyfq4VF0nADbwHyN7 zfs13qh8Nio67DFOkCSZOpHdlpBm7nxLHDr+rue5nhSxaKvwNkwLJLtsqfjVmqNGancw yF3EO38XIil3gvdouK6vVc+jCql2BcbTDSEUl5so04O9XhA2QuPO+RBoX66OnvUPvDKB w7mdQegUtYOcsdx+z427Ly0IV0jMPO+J4trUkKzO5WIMIESu9XHPo1sCm+PVojYinsjr Nm4H+yREN3mQfBh+M54pHMASY1w7SmS/jVIWZcuore9jQ6zV7WCvEPO8HRpgs+T0F+gt gN8A== 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=Q/cQ+s7tQtjC/OitTWv7XOq+cPm+R5vQ5zct/mEOgKY=; b=G6y8Lby+D70HXZT37jISeKG3eld4b+49XC2qxjhgyBtEdo1AwvjPD+a9hh+gHiSnFA xPDRRDQrLo1G7AnagQwtU+aAlfKFqlXWBDTM5TKLDRUK3o/B6HPIE7e7lGaRMIarvdXl YgThs11/WQv3EoTd+1I6BsIqHJYgBTkVe2LpP8ngHsacXfk6E8wKtu2/lAoY9dXiu+G9 2Z91rubDDjeSg/lwuldSKtQEdZ2EmkzqXwLL13lqSx/TAWKfJGO9ywd/sl3rrqC2T4ah +8Pt/vhJHkzuJBTyoq/AQLWAofq8JvUN6MILoVn1A8uuAskQGlGw8dYgSrJN48GDEdyC ngUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="gHdi/t9o"; 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 j70-20020a638049000000b00502f4be647fsi3588147pgd.641.2023.05.26.04.50.09; Fri, 26 May 2023 04:50:22 -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="gHdi/t9o"; 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 S243350AbjEZLlB (ORCPT + 99 others); Fri, 26 May 2023 07:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236875AbjEZLk5 (ORCPT ); Fri, 26 May 2023 07:40:57 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320DA13A for ; Fri, 26 May 2023 04:40:56 -0700 (PDT) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34Q9qKcf012829; Fri, 26 May 2023 13:40:44 +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=Q/cQ+s7tQtjC/OitTWv7XOq+cPm+R5vQ5zct/mEOgKY=; b=gHdi/t9om+jjKpDK0hLDKd5Nlzg/LS8AEPW7NN+OMtb+wZpLg2ii9nhCCrNANKniCc+I B/A7VLw9/476mOlSakzzP60KUl22NHIEKaLnt2oRgqiQhfNZgtUGhQmz676EAFR6t0vr lhCKEm9yXaTnEYeigzmrvL5Dys8MGMagqaY/KciWemvzDbeGLsOKda8DHf5KtzaPVmoM 1wsIbTuIBf1nLVFoLt8p/MRL2qlj0vj4veVIHNY/el1YsXFzPVTkgTTLNasDn+EgRMNG WGAsjSo/UWyU6JzgyBAVNx/i6Yd2LryQc0I2GVVahPtEjnrkRVDsMXk88/SMDCJUMueU 6g== 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 3qt39u1328-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 26 May 2023 13:40:44 +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 E049710002A; Fri, 26 May 2023 13:40:42 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D7193229A9D; Fri, 26 May 2023 13:40:42 +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 13:40:42 +0200 Message-ID: <62bd9682-b768-8be3-7a2f-0eceea6d9772@foss.st.com> Date: Fri, 26 May 2023 13:40:41 +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 Content-Language: en-US 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> 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, Applied on drm-misc-next. Note & fyi, I fixed the following warning, please be sure to follow this rule next time :-) WARNING:BAD_REPORTED_BY_LINK: Reported-by: should be immediately followed by Closes: with a URL to the report Many thanks for your patch, Philippe :-)