Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp208522lqg; Fri, 1 Mar 2024 02:54:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXWtw8HXsxk2PCFep7Irrax6Ghe3LsDnn8UAFph38e37JCPGZFfS61rtRN2dTuBIwKv+rajUah1LP2QG6my4H0Dui7EzjdvXGvT54vXeg== X-Google-Smtp-Source: AGHT+IGrK1+59lvQMLmJypVBCTl44TL8g0y2qD4Hu3M6IkDavf8a8P+OZWu+tTc6eYyeRSqNMOl4 X-Received: by 2002:a05:622a:1312:b0:42e:c5e6:d350 with SMTP id v18-20020a05622a131200b0042ec5e6d350mr1194506qtk.15.1709290474664; Fri, 01 Mar 2024 02:54:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709290474; cv=pass; d=google.com; s=arc-20160816; b=S405XKP5RlTxHZ8EaJRcrHUPPrevx6S7blrI4wtqUW645XPR82EtozpYb6In9a4lyI iVfIlR6HcJVwBhA9D66DgakWulRxc3lDL4GBwP09vJ2z3dYJNkj3gpXqAMQ5CxvjSbI8 JWr2/bvbqir1l6kc/rehHpGXxtnQ0iN0KzU1Dc9Z35Trsfo6X8lsS/lw/xuL4hakEFLe FgKPJiqe4fuWLFBz6hosVmhEeGvhCsw7pvgO+1XneYj0DjYFqTzqMrt+4QrU+FSm60WD RCaGQDOFPxIX5coa4jCFRLGnLof1HMPfagx9jJIzZVbUe+GvctYND+nadHmeOYadQySS kW8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tjGEhzuhFUDcE6IMM+mL5TlbxL3v8+X2s2hqXwmwqxI=; fh=Npf/EnuVXGZ+oOZc8c4iiIC0uMqQwe+lpNspj0h9Sb0=; b=IcnB0Y4HGylvfRFnYVcX7sQrIMFGp0ngHLf9NAKCzYZ9NQeQ9pJAAVWFr4FYyktj0K m/q2shVCrT0WBq3WaKqFMmvkU4a+lBTQik00diGTT5qUFdmWAfoq25CccemtkBg1tajP +JqKfEAIwN253MIUZKi6nt9MIfI9vPPv1ZW+LU7zObZUV0/BGTjc/4Cy500t7wYpBlPi z1kErqoAsHq7vcQGNt0cmHV+HeMzAwnaQRYONVYPbP6f/uZ5ZZvFaBeNiXHk8P7/PyOH g2tvRbK5mh2m6F39XK5rgjtQ5b/0lnSARzPzv2U1U21nGO5B7NgpZ3UCBaaui46RIEVF s5qw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a6lffpy5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-88288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k2-20020ac86042000000b0042eba21b2c7si3023781qtm.636.2024.03.01.02.54.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 02:54:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a6lffpy5; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-88288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88288-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C3BB51C22451 for ; Fri, 1 Mar 2024 10:54:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73D3D6BFC3; Fri, 1 Mar 2024 10:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a6lffpy5" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F4FA6A352 for ; Fri, 1 Mar 2024 10:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709290467; cv=none; b=PgK8cHCMyfKQhpij/VdxOgtmaXf2BrzcIkDWnZDpn3fDhWy/FCOBv0/zBw7DtiJ+9tdlXktdiOUrxDT3OLgFC37kagFQgZW8uvafsZ9+2tXVxuWrQfuQmlKMPGVoyzTjlCf7ZqibrQTkt8oFQ7SeAyM/JiODrF+YEJJX04ZabH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709290467; c=relaxed/simple; bh=9yUqjRiZDnW0sxFymCG3HhyOZ20gbsK/kpqIlF8AEuI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WYT6w/D/9rkjylPJwPTsS+80I9I2NpmdTCpFgC3zS14B6E5iKp9GWpvkTS+APJ0VctK5aWPwb0JYdzWaWJhT/6adjAdPNSnnyRZJpJIwaz2ufp85HMHO/ZO2Krnit/5NKZ7SqMMmoxjGVJNGxJLLuuvFrP5nbe3W1mOZb0dNHd8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a6lffpy5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709290464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tjGEhzuhFUDcE6IMM+mL5TlbxL3v8+X2s2hqXwmwqxI=; b=a6lffpy5gQsfuT4K8MEEjear1hptBKoogxLQUm8uq6CSHNQVFhFDaVM5TXLIihoGy0SS0g 9xZeRIBYQFwefKANsfq4aXVYc9m/NTNesqocbu4lzUPqsz/l52sN2lws/8M3FaRIYIWNSo rPn0vhAmQy2gNUL+1GX5tBc3B+bVAgU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-b4NeP0x0OrKwLhGq2lOl_g-1; Fri, 01 Mar 2024 05:54:21 -0500 X-MC-Unique: b4NeP0x0OrKwLhGq2lOl_g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1CCB106CF91; Fri, 1 Mar 2024 10:54:20 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7014492BE8; Fri, 1 Mar 2024 10:54:19 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6AB671800DFF; Fri, 1 Mar 2024 11:54:18 +0100 (CET) Date: Fri, 1 Mar 2024 11:54:18 +0100 From: Gerd Hoffmann To: Aleksandr Burakov Cc: Dave Airlie , virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] drm/qxl: fix NULL dereference in qxl_add_mode Message-ID: References: <20240301085511.23298-1-a.burakov@rosalinux.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240301085511.23298-1-a.burakov@rosalinux.ru> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 On Fri, Mar 01, 2024 at 11:55:11AM +0300, Aleksandr Burakov wrote: > Return value of a function 'drm_cvt_mode' is dereferenced without > checking for NULL but drm_mode_create() in drm_cvt_mode() may > return NULL value in case of memory allocation error. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 1b043677d4be ("drm/qxl: add qxl_add_mode helper function") > Signed-off-by: Aleksandr Burakov > --- > drivers/gpu/drm/qxl/qxl_display.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c > index a152a7c6db21..447532c29e02 100644 > --- a/drivers/gpu/drm/qxl/qxl_display.c > +++ b/drivers/gpu/drm/qxl/qxl_display.c > @@ -236,8 +236,10 @@ static int qxl_add_mode(struct drm_connector *connector, > return 0; > > mode = drm_cvt_mode(dev, width, height, 60, false, false, false); > - if (preferred) > + if (preferred && mode) > mode->type |= DRM_MODE_TYPE_PREFERRED; > + else > + return 0; > mode->hdisplay = width; That doesn't fix the NULL pointer dereference in case "preferred" is false. I'd suggest "if (!mode) return 0" instead.