Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp680919rdg; Thu, 12 Oct 2023 19:01:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEofT0N8gpj7nBbO7qXOjsRc03YI5YJYxM3K17/M2/PZGBzCH2Twekv7NZvdzEkbqVp2ad X-Received: by 2002:a05:6358:339b:b0:143:9235:9f1f with SMTP id i27-20020a056358339b00b0014392359f1fmr19633184rwd.12.1697162501357; Thu, 12 Oct 2023 19:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697162501; cv=none; d=google.com; s=arc-20160816; b=oP8klMjuzYm4+YnNq7JEG0+xgbuIK9UKgeMRJ9FqX+pKimcLPDQT0W27I9h20PVdge xDZvhLK4nkE4lm/mydIebiPWEcv1Lx8PVTVn30n3mFlJAJ+pzMPEr1+Nft3jdjMeYsN8 JcelPtozaqhs+6xBxXMwJ6amh/5g/gYF57CVexBLfPsdfOdQ06mXildFGUoOqB37PI/e NBn4Hgy1ueN6CrDR8E38UNUuvhBdfCBZvD9V7fowBuvsfVKs0ijWso/lljJFhyRewJNW uxpsxp8OKIwy1iGhVg0CLWz4ePWv4HLW04HvhQsv4jjcUxB8Z17IQpL44HDY7ZRrRcSQ akZg== 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=5Tz6+l/Q7+gJHUeIVALmKaMD4X5CcMraadvh54wQsoc=; fh=nEHYfah9z1x7cbfNWV39DV6nC37+2Y6RAhrmeD+VGzo=; b=0n3pfvUgZF1QJ1olz3SQNOhafLuQEDOErv7Ton30Sg1FzPGKl3qzX4pQLuQD7a+625 NuB/RwNajNFTL/44Lc8BFF1QYlWHitiZBRntNeP8yKVQzqSzstviqiVh+WYjOWoIbP7n FK73indUEj9pOVY5+dUJDyDtsZPUnQXymE6tXjjWp15SJHaMETeqdSQ6PlSWPgeKX2ZF 966tDRdW7N5LwV+IE0JJj622jHNhkbQ26gO6ycdfcVNrfqIjB8yEQJEzHX14HoIpGAAV 8PPlmTjG3MWgggQhhNTzbwpgmEYLCYEClCUVoIxowjAlTA6BDHonHkA9hbJ2+DKaAffb iVYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=WHxvWJ2B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id q6-20020a056a00084600b00689f1186cfdsi8851648pfk.29.2023.10.12.19.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 19:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=WHxvWJ2B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id F15B181CE872; Thu, 12 Oct 2023 19:01:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229448AbjJMByd (ORCPT + 99 others); Thu, 12 Oct 2023 21:54:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjJMByc (ORCPT ); Thu, 12 Oct 2023 21:54:32 -0400 Received: from m15.mail.163.com (m15.mail.163.com [45.254.50.220]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3094BB for ; Thu, 12 Oct 2023 18:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=5Tz6+ l/Q7+gJHUeIVALmKaMD4X5CcMraadvh54wQsoc=; b=WHxvWJ2BWOQp3LI1ZmB2S av1mDSUnP9JWp0HX8NL1YhFI6gjTt47Pip0ahqsXo8Lm2y7jWDu5U2A7wWmAidWa iPsVUThkLvZOQhN4c0GJDTObTQG4p1PK5J7VzqMbRPI3wayvSyv8OCfS9Yd51H3u EaytMOawdDyZGsC/TYpNiY= Received: from icess-ProLiant-DL380-Gen10.. (unknown [183.174.60.14]) by zwqz-smtp-mta-g2-2 (Coremail) with SMTP id _____wDHr60poyhlbuSdAQ--.16620S4; Fri, 13 Oct 2023 09:53:53 +0800 (CST) From: Ma Ke To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, guchun.chen@amd.com, yifan1.zhang@amd.com, Tim.Huang@amd.com, make_ruc2021@163.com, zackr@vmware.com Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/amdgpu/vkms: fix a possible null pointer dereference Date: Fri, 13 Oct 2023 09:53:43 +0800 Message-Id: <20231013015343.290456-1-make_ruc2021@163.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wDHr60poyhlbuSdAQ--.16620S4 X-Coremail-Antispam: 1Uf129KBjvdXoWruryxAF1xKr43KFW5ZryUtrb_yoWftrg_uF W8Xrn3Zw43ZF10vr17Zw4fZwn0yF15Za1kGr1Sva9av3sFva17XryDtrn5X3WxuF17CFnr X34jgr13A3ZrCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKpnQ7UUUUU== X-Originating-IP: [183.174.60.14] X-CM-SenderInfo: 5pdnvshuxfjiisr6il2tof0z/xtbBFR0IC2B9ofy3QAAAs8 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 19:01:36 -0700 (PDT) In amdgpu_vkms_conn_get_modes(), the return value of drm_cvt_mode() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_cvt_mode(). Add a check to avoid null pointer dereference. Signed-off-by: Ma Ke --- drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c index 7148a216ae2f..db6fc0cb18eb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c @@ -239,6 +239,8 @@ static int amdgpu_vkms_conn_get_modes(struct drm_connector *connector) for (i = 0; i < ARRAY_SIZE(common_modes); i++) { mode = drm_cvt_mode(dev, common_modes[i].w, common_modes[i].h, 60, false, false, false); + if (!mode) + continue; drm_mode_probed_add(connector, mode); } -- 2.37.2