From patchwork Fri Mar 1 12:26:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Burakov X-Patchwork-Id: 208815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp1040226dyb; Fri, 1 Mar 2024 04:27:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUI4B5E3L3IMnb7m4qo9+c2MWtvCvcbCJBbSNn+ODnEefyDp9FabUJWnwyxbcHx8Rdm/GAa8xVa83/H8v/lFDwT9TK0kw== X-Google-Smtp-Source: AGHT+IEE11Z49mB4SJjAV9AC2rbj/r2g+4CLCDilfcUh1BkM+ki6x1Pnk9dWy0dIbZtMa1V4GV52 X-Received: by 2002:a17:90a:ce89:b0:299:14c6:4fc7 with SMTP id g9-20020a17090ace8900b0029914c64fc7mr1353698pju.13.1709296032898; Fri, 01 Mar 2024 04:27:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709296032; cv=pass; d=google.com; s=arc-20160816; b=OTydal4laN5YVVcnfdccUPuzXdcDnwMMcgQ6OFEtnVKLUaI1GnqK0EIC11E9Sos+iQ o8R5EdGQgIqLAa1UgQz8EQmqkeA100Yj2HSlg8O7riGmQ20j0MLlKYRrwRMxF4cfSVST j+RH4NmMfs3akTTqgyjLVe+57Ga8fjfuS8Q0jX9PVi7LLjM+JI6CkXxqsCkujtYwkpic ld1AUgIhErywZcQuvAmKCGL8khyFZ0oiQa3/Td/BJgpDYfWpc7jDAVZHhmSvMAZwvqOW rlQ5nrsdZeYNlbjjUc7hlBiDV+hsE9Y9JEZVFx7hoVnHzY/iuNVn0Rocr3+DXRzx/Q3t Ga3Q== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88396-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x11-20020a17090aca0b00b0029b288f1100si691346pjt.49.2024.03.01.04.27.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 04:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88396-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88396-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B1E962842FA for ; Fri, 1 Mar 2024 12:27:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF8556EB53; Fri, 1 Mar 2024 12:27:02 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792315382242177124 X-GMAIL-MSGID: 1792326797328860935 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 *connector, return 0; mode = drm_cvt_mode(dev, width, height, 60, false, false, false); + if (!mode) + return 0; + if (preferred) mode->type |= DRM_MODE_TYPE_PREFERRED; mode->hdisplay = width;