Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp969290rdg; Fri, 13 Oct 2023 06:43:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSWnta67aC18u2KzMAil4Opk6SK5cumNiDdpPyj3hw1asEvhavmJi2tkSNE+7YhLQtJn0H X-Received: by 2002:a05:6a00:4784:b0:68f:c1e0:a2c4 with SMTP id dh4-20020a056a00478400b0068fc1e0a2c4mr204624pfb.3.1697204610871; Fri, 13 Oct 2023 06:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697204610; cv=none; d=google.com; s=arc-20160816; b=X1oj00/Ix8tlijgphXjWK/IWsDW9GOeZnqbm8RoM4csmubLd0QKc0zQUgBtfwsPbhS 8M7FPW6t0bZ+vs02CvsQYdMu8BB8Cfn2xUrLP7Selo+kAZEGQyJPyq3GpY1ds0GaXtpK hkuXHfy4rTWup0hxliCMCtZQ4wgOBzloygLMd6aqMuXegG9qpHXnxERkZi9sXeTDQMoN cT0BLk9kcaNwvyAx031v/s0imgAGByV1+zxwFD0R/258GBqeOz+J/JR3SY3aUnQhqBvG 6WfyaQ75N23wfpNkbsEZM8SDHkLR/V4leXv7q5O0obTZSd8cmRo5sNiLSDRfHFwwgfG0 o7Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=VnWEZv1MNtgqh9gti2tLWs0h9m12y4MRumc01RdiEtk=; fh=VnIhGa2IGUBex8JuaFp7pts8d9/iPF6F6VgkCbPmpVI=; b=GUgIHgsKway2XP+zWqcJZqCyN1rXwvHEI2h+6KVdGeRAm13HZoAmgm4e0aIeBbZj/6 bZriy1C/P4vwMkaOEM2+J529eQQ3CLzeQKR5N7xux/BIWhf2OtpS6rNjkcgZJ8I9U8fO T9npIvmuk3ja79E20tR+q8k+DP5BJ0ORtYH2iSieuAgHHJzGlHMxh1jms+UkFUfL8uKH BLRmEAfbzgansr6YVJcTtI5Ei6c347sz/SAxPo8pBxh2rsxJq4ZM1R22p801FoxYEVQS /B5xn56qSjicYFIrToR+D8aMXUpzkaikrjsjjXR1dr3SuwZWKj30ydxygXDJ1aDJOG3J TsiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aEM4FYBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h20-20020a056a001a5400b00690cc6f7598si17573392pfv.247.2023.10.13.06.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 06:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aEM4FYBX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 5A51B801C93E; Fri, 13 Oct 2023 06:43:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231901AbjJMNnU (ORCPT + 99 others); Fri, 13 Oct 2023 09:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjJMNnT (ORCPT ); Fri, 13 Oct 2023 09:43:19 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7797CC2 for ; Fri, 13 Oct 2023 06:43:18 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-1dcf357deedso1141271fac.0 for ; Fri, 13 Oct 2023 06:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697204596; x=1697809396; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VnWEZv1MNtgqh9gti2tLWs0h9m12y4MRumc01RdiEtk=; b=aEM4FYBXMJdoOBgUSNw/pvqNkIHQucPnxQhof28rz4LIGWBdBWLUKSmfOXFAwYuYBC +l6dMTuxC33bbuiBm4KNtrENI63UKQZlM4T1qYmweUi3mTbqGbwmzBdYAMWI3TCYNhNW owxqwjdrd2bSnd1WbRn1nDl6XOHHHvT7Vi4d+1p0mh4YPXbiwBqqVZ62sNtn1NBjNj2C FQPYyKuwCALYn6sT18djejy6K7Gg997nP7cEOhg/Y1t+mF/zlUw5zjg+Qpt+/SwtLdzt R1LiESNl/bZnZQ97ArBZ6EzU8yKKuX1F2+XzpkWwKGZR6/BFtycyr5KMFrd6pcIwO6Ga B4Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697204596; x=1697809396; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VnWEZv1MNtgqh9gti2tLWs0h9m12y4MRumc01RdiEtk=; b=iiELdKIUdjB3XvgIMrxWpRtpz8LhEDVcrT97WReIzL16Ult9+J0EEUs4cbGz9iFfl2 fj8VFUdGhgDNMKBiG5z+fI4Qxlr1lwOMz2wxkgstkdypkkqpvat9p1neKuQX7qhIGh3K tIGaJzXeR3adkQ8OdYuwNQFG95AOLk8mA7UyjqHISE1Z1D6hFhNVwLuFwZIXjmwvzs7T hYKohhiG5Tn8WH+/KKWCJHHuIyEDCiP8qixNBX3Ja//3QrSlXSJXkj4yicxscmbvJl2j o7zu4HwdmlSxQiIbYa4RwwjT+LBl4W+66rNbHp3V6PMKpR7L20lG19OG5k25fSfrejU4 WcMA== X-Gm-Message-State: AOJu0YxifPiwf+E/mUPvpIXp4ke4XbRs84C4VfS0aGPzGsy1dwE2a/KQ k/tVPuiOBTjrKgtsvZGIihGWtONLHsjaQQQmTQc= X-Received: by 2002:a05:6871:4414:b0:1e9:9537:c1a9 with SMTP id nd20-20020a056871441400b001e99537c1a9mr9024226oab.12.1697204596057; Fri, 13 Oct 2023 06:43:16 -0700 (PDT) MIME-Version: 1.0 References: <20231013015343.290456-1-make_ruc2021@163.com> In-Reply-To: <20231013015343.290456-1-make_ruc2021@163.com> From: Alex Deucher Date: Fri, 13 Oct 2023 09:43:05 -0400 Message-ID: Subject: Re: [PATCH] drm/amdgpu/vkms: fix a possible null pointer dereference To: Ma Ke Cc: 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, zackr@vmware.com, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 howler.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 (howler.vger.email [0.0.0.0]); Fri, 13 Oct 2023 06:43:28 -0700 (PDT) On Thu, Oct 12, 2023 at 10:32=E2=80=AFPM Ma Ke wrote= : > > 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 Applied. Thanks! Alex > --- > 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/a= md/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_conn= ector *connector) > > for (i =3D 0; i < ARRAY_SIZE(common_modes); i++) { > mode =3D drm_cvt_mode(dev, common_modes[i].w, common_mode= s[i].h, 60, false, false, false); > + if (!mode) > + continue; > drm_mode_probed_add(connector, mode); > } > > -- > 2.37.2 >