Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp253176lqg; Fri, 1 Mar 2024 04:27:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWNwHQPKuMGR+hiHHFUozz3cBiZde1UNfnQQs0QUgl/QcuE2jF0+7xMuI4BxnXmlkw1/qvPE6xpoe9t64OKNNYRzKl69sgtBRdHpdLEQ== X-Google-Smtp-Source: AGHT+IHNJ1vyvYO6q4uQfYepI0gS1aebzkkaGZGuQ4N/OIHNqtJJthyBkoRSrVu8BoQAj0IEc/4k X-Received: by 2002:a05:622a:50c:b0:42e:b793:4a7c with SMTP id l12-20020a05622a050c00b0042eb7934a7cmr1553474qtx.8.1709296026097; Fri, 01 Mar 2024 04:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709296026; cv=pass; d=google.com; s=arc-20160816; b=XbxE2HdoMy7kZ12op+7gTd18tF/O+34Z7rrcq+yHCMogfCre5IZAc7TcACgOcgLw9x ILLP0j+4KbIhVePt4I7KvgwFFfRGOnhVFkudW2QIuuVJp9Q5xN75BqQYg08ZSV3bFFJi p1QRh7RL9/E2OT5DMRZN/bjgraprK6SAYjSj6T6ebo5r3uYyUvv1BjavPlH+1fxYAfTw VKr9nqTmvdD6WsNrmlwZZKeDxUAJR6u+DnpQX7p/cwtBv66Wz8vlDm9zc1B5EnenEhaP KgI7SeSbLPbwGQpMH6UWjr5plbL3Hk905Z8YOsQo+m0VTs0I3J5IwnJzpV7Td7G+kNOZ DizA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=GPmQWvjQuc1pVJSK54+GnJ6cGFBHUxKlE2p3TVblCUs=; fh=yMXZvFsykfWXlpH7HjUcP9nxZPyfqAlkQnmcdSKgkIM=; b=T6Nsx/DKgVmKzHR3Cw01BHryckAIQHptJDu/f0Zxj1UAOsxVZeAEUGBWR50h4tc/hY gj4GSJDsW3fqi+Y12OhVXs+3kmo1xO+haJqlbY8Gm3bthcFbevQc0/9EIlJlaaxM29yK ceOUln9y120SQdU6IEsc4pruYIm9PkH1rCd+7qLTScFxw/d7D+Dcz8996iiUPUQFAsGp pFHoscRaTSpXpky+LiQgFOw5IDCjyYxJSyA+MYPV4odW0N8dOAx1b/PfWsKzOSJYYLjn c3msSouVTJWn4IcM3wHXFL2eEHsznqvgY02bQXrmhhaHvpd3l2gZ4+30cXB58MBlOwwu CWoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=PdctvGqO; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-88396-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z16-20020ac875d0000000b0042e4b823f2asi3267569qtq.426.2024.03.01.04.27.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 04:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88396-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=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=PdctvGqO; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-88396-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88396-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru 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 C242E1C22CE3 for ; Fri, 1 Mar 2024 12:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC6D56E614; Fri, 1 Mar 2024 12:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b="PdctvGqO" Received: from mail.rosalinux.ru (mail.rosalinux.ru [195.19.76.54]) (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 B63CA2AEFF for ; Fri, 1 Mar 2024 12:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.19.76.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296018; cv=none; b=HJSPPd7/3ZruXlqETO6KUkX/ZtB4dx9/ohZjQeRTbnVSkylUoqXAOK6zgQEA78AeK3XlUzwLwNPy77u7smqxd03vX30vzNmkThKHzY8d0GEZUPpv1nd5QRxAitsQf10diE+J/PAht7luFG9WPKGZyHfLx7b9M0GYNGI1sPkbxaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709296018; c=relaxed/simple; bh=j5D9U6KjNVFx9zJvU329TCD0lS74yEhf5AvcIdP3EC4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YLZw6321WVigM+3Xb8jZbtSmGsG6Kv4k3jTfh544/OrOg6z0PlaMM6+LO+yFXSx5pOfyMqrY7G3r1oVl1qHmWFU5mLVlAgaFw0w4VdfkJk7Pu/nomixV1Fp5AG4rXjJswMAVJxjfF7oF62l/nPqH5qrYtHqDLQLQfV9QxYwvSoU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru; spf=pass smtp.mailfrom=rosalinux.ru; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b=PdctvGqO; arc=none smtp.client-ip=195.19.76.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rosalinux.ru Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id AE28ECFF46BCC; Fri, 1 Mar 2024 15:26:42 +0300 (MSK) Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id fqAs-W5z0ecx; Fri, 1 Mar 2024 15:26:42 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 84DBFCFF46BD3; Fri, 1 Mar 2024 15:26:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru 84DBFCFF46BD3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1709296002; bh=GPmQWvjQuc1pVJSK54+GnJ6cGFBHUxKlE2p3TVblCUs=; h=From:To:Date:Message-Id:MIME-Version; b=PdctvGqOjq3p2Zi7u3eZmpT/nGJf2zXfxbj9ZZS/6BvPa9WdbccuaQU/a1buAlzaC lVQ12ZpwmWjDVedZ0smgilBF8Z9Pe6XTnpIJ6krCG8aId80PRbrOGaVlptqYNZB+Yr wSAiQLLqn61BPdFa6L2VO57xPNZseHWfXUpCL19ZXoz4/zXVNFK7qBaSHTzKgPkFoy 4wwsxFNmCIXStxhnrXXpp3Vh9fwJDbH6AgIYKG8bDv7Mhw/uP6sQ5KgvDZZJyCZkqW farm3lc+/N43U0R7OhXA7dtka1vlBlx1I68xZq6QYF8bhRJ69UMWEhvPE3fOR9L9Wv fmVWP3Fdhrk7w== X-Virus-Scanned: amavisd-new at rosalinux.ru Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IDqMVs1C3EXX; Fri, 1 Mar 2024 15:26:42 +0300 (MSK) Received: from ubuntu.localdomain (unknown [144.206.93.23]) by mail.rosalinux.ru (Postfix) with ESMTPSA id 48574CFF46BCC; Fri, 1 Mar 2024 15:26:42 +0300 (MSK) From: Aleksandr Burakov To: Dave Airlie , Gerd Hoffmann Cc: Aleksandr Burakov , virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2] drm/qxl: fix NULL dereference in qxl_add_mode Date: Fri, 1 Mar 2024 15:26:35 +0300 Message-Id: <20240301122635.25058-1-a.burakov@rosalinux.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- v2: case with false value of 'preferred' is now taken into account drivers/gpu/drm/qxl/qxl_display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_= display.c index a152a7c6db21..d6dece7a0ed2 100644 --- a/drivers/gpu/drm/qxl/qxl_display.c +++ b/drivers/gpu/drm/qxl/qxl_display.c @@ -236,6 +236,9 @@ static int qxl_add_mode(struct drm_connector *connect= or, return 0; =20 mode =3D drm_cvt_mode(dev, width, height, 60, false, false, false); + if (!mode) + return 0; + if (preferred) mode->type |=3D DRM_MODE_TYPE_PREFERRED; mode->hdisplay =3D width; --=20 2.25.1