Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1979713rwd; Mon, 15 May 2023 05:54:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4X5JWB4S4bWKxpE/gJ4rMpr/ur8rtESHVkMBjgks7DGtUv8PxXR+aiJ3RA8Bkp4HBl+fUr X-Received: by 2002:a05:6a21:6d9a:b0:100:607:b997 with SMTP id wl26-20020a056a216d9a00b001000607b997mr37307192pzb.49.1684155293667; Mon, 15 May 2023 05:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684155293; cv=none; d=google.com; s=arc-20160816; b=Ensql22avazc8O5hfGfpL5QcwY4BHLyxRTtJRKS8Qob/nEETxmdFWmLwpsLvYbj5hv 6W2jA4fzyStpNgISMyxGYN1lcpV8x3P3fZZ2Sj2OIbfxFK+ItTeSCjdLss9PdPKKwLTX dUud4Uy15z+1QE/LaY4LDR/rSkB9UYva24WKrhVkVrXLEqgDmOSRKfrkiWbo5LI3ZTDZ 9EAS3MHIs4tXNW/OrFJTH0DHNCb4C2o1BhgtigOfhZ9/Zi0wEAEH1Awxd+/1iQ8I2MVg HEhqTBKG6JbcuRfHGe+NPXmy0tHpzrhb2v4VEKCY7DdLMlDiRJWle2Bv4RIstUGkD6dT n+RQ== 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:dkim-signature; bh=C32TBRVdktwQzHv4Hb9kGIbGc9gWRr1UiGA7i4gu28c=; b=b761uIo+CRY2SgxmJEibTUuLLUBk0pICzzE8zLB4ndT5tfAo2xCKtAj+7XShvfyKKB p0sKZhTPFRLUv9uqQ6u5nXBJbR88gRcDbZdxGdilg9+LP9Vs0k1E+S1ttheuYxQ6Qr2i MA4xmQY5lQHqmFCM6p97lqpsdfQR+VNDO5Lwpo8Y8tAzgt2KaTPItJ9ttoV882gMnaZX FoqJwL9V+UU5PGOtOiEThE/Aq2B6rR3KA7KN4GcIUG4TPywGofSG5JvD5WLS/ilRhRMA Aw4SaTMpcr1UN71xdGcXWlpxGQjeLtoYB0luGLjxZmrHfhwcGe+Q82zanruqSe1hR86L l/UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=KOLkSr34; 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 n127-20020a632785000000b005321c340960si5180611pgn.811.2023.05.15.05.54.37; Mon, 15 May 2023 05:54:53 -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=KOLkSr34; 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 S241904AbjEOMlQ (ORCPT + 99 others); Mon, 15 May 2023 08:41:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241953AbjEOMjc (ORCPT ); Mon, 15 May 2023 08:39:32 -0400 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41E6E19B1 for ; Mon, 15 May 2023 05:38:43 -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 34FBEC0U012016; Mon, 15 May 2023 14:38:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=selector1; bh=C32TBRVdktwQzHv4Hb9kGIbGc9gWRr1UiGA7i4gu28c=; b=KOLkSr346r3axUqgxh1EKwUVufgprJqMt/ERbEIXgSC3zQbPwTWGlqpalAvASIK1gS/d SlCZYEAuJI+jfNkNKiN+DP0l8IVeTfoCXlRncyu2jWN+UB2sHUDEbTmG/vUfgRDIgt8l o8P4w3/odxRJ5AXeTalIPDpnBMg44coVqTGwqBKtbZqOYIeZvWKdk1AT8x26ZbuDRvWi p5D6+ABmq8JGnGkVwrrz9ejtkqkNlNLFAOA8HApE0GPkVlV6QI7591GnwIMIuBPRB6Sm 5dNR5ogjnOwNDpPADE010LonViDBtF4NYJ50f4GPfJXXzTlRwoOaUy5fp7aml+0QEHzW qg== 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 3qkgqwsyy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 May 2023 14:38:25 +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 766F310002A; Mon, 15 May 2023 14:38:24 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node2.st.com [10.75.129.70]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6C1062309C5; Mon, 15 May 2023 14:38:24 +0200 (CEST) Received: from localhost (10.129.178.187) by SHFDAG1NODE2.st.com (10.75.129.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 15 May 2023 14:38:22 +0200 From: Raphael Gallais-Pou To: Yannick Fertre , Raphael Gallais-Pou , Philippe Cornu , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre Torgue CC: , , , , kernel test robot , Dan Carpenter Subject: [PATCH RESEND] drm/stm: ltdc: fix late dereference check Date: Mon, 15 May 2023 14:38:18 +0200 Message-ID: <20230515123818.93971-1-raphael.gallais-pou@foss.st.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.129.178.187] X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) To SHFDAG1NODE2.st.com (10.75.129.70) 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-05-15_09,2023-05-05_01,2023-02-09_01 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 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