Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp171654lqg; Fri, 1 Mar 2024 01:25:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUyvTTwu8oLycuKFwgsNxCo1SytThb1YIY2nzSsvPV415ouIPM68NLo6lHgeYeg27dFQO8+XkZiibA6ALPLnkqMg0D3h0DtdG31mppGHw== X-Google-Smtp-Source: AGHT+IHcmx+X8WVzOEhg++Qhd1iRSI1vs7wUShu6k/V/N4sIJedT5knOh0JFu5sBztF1m46WDHOK X-Received: by 2002:a05:6a20:12c2:b0:1a0:e707:8c2 with SMTP id v2-20020a056a2012c200b001a0e70708c2mr1128208pzg.29.1709285133628; Fri, 01 Mar 2024 01:25:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709285133; cv=pass; d=google.com; s=arc-20160816; b=ZH7rV9O+lqlXcSgT8tamiJK5gLwKPaSUUDKsD0t0h3BWodUjLQCVqbE/MHOJDnzqAz Kb+0Zfne1h4uk5lnmM7idVx8Rp2USZPHnwWFYqCTj33VwrD9OuKar7FQrgoEC1VswJx6 SxH2WfOcOLIHtzLMfWw/k0RzGFWNEgKUyA+HF2smF8EeSZq9iSS1hFmywrt/UoLBFLdG 9ehemyc5x7g5UYSHtBdQ8jWyaxdX3OGMEQiG7ALg9Hax4YcjWCV3degDrFH35sFQ045J VLQ9wU7eCTYaZQOsHtzggBiq/pMc4j8lMGWrSV669KZiXpmUV80Ip0DnC4GSzQKPMT8w LWvg== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=f2qKsIAGkUNEVelOg7DTK/0b4IF/e+zG6QgMW3olvD4=; fh=yMXZvFsykfWXlpH7HjUcP9nxZPyfqAlkQnmcdSKgkIM=; b=Z7XXQj+Wnc2zeR4YjxJXdmggqz2qQNpASMPJuBZGMFmn8kulgKjzCJXi2jWT0xsBww VawKZpKWEfgS/1X/88JWS7OChKoRKYhwoHccSpuQvhNdbuzv1i+/lVTEK8lC1HX9ZNNN q/QH3gUaymBD0DYmZwxo2vlFXAe47jcE0sVW4ePNMIa052Bu+/1yu9M/hsBwV4ztl4IW VX2HbdKGo6hqWQvEB2odtg+TLwUAopuveZi9eM3EB7QvlrDw5SCvHErzoW8QjrWuByWU lS7wEApxFD45dgSV2zkOtKlep9GcIqzwiizBvPb1r4Q9jJiratzndq0RucUuP2WOIQC7 Txvg==; 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=P8auQz5C; 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-88142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88142-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k2-20020a170902ce0200b001dcb7d02094si3270273plg.392.2024.03.01.01.25.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 01:25:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=P8auQz5C; 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-88142-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88142-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6C7CDB2747D for ; Fri, 1 Mar 2024 09:06:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E016A337; Fri, 1 Mar 2024 09:05:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b="P8auQz5C" 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 2EC546A03E for ; Fri, 1 Mar 2024 09:05:43 +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=1709283955; cv=none; b=gzFet53CkER+qEBOX9iya4IWb8rbjdDCM8XGrryZpJZXqH3KvQG/7l5sZIgpRk3dYHWHur4m/WMj62pEfJi7U51v0IMjs/SP7RSFNNnjUSzJ0kyzMls59zLo6VF+lqqp7ixS8NSMStTeHUOAiYrcrR44ErvI+BR6lMDETD9luDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709283955; c=relaxed/simple; bh=U6zrGDf1CH9J4v5DCBN2pKsyO7iS9kDU6k4Ptp3kKy4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mo6eJLROW9hxQH2hBOpR2T6arW5FW3JAjTD4rdurh+Vv9wGRwTSMpelBPiNsNsOUrTf9U6ZtE4pMrZcyg5A/32YkUw4xkIqYpwux2EKUBBSju4pYu0iTw2CfM7scRQNCRYi0UNRGK0HAl3ROu7gP/0bmx57mbNjVcslHzYyiPUA= 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=P8auQz5C; 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 20489D998EC3B; Fri, 1 Mar 2024 11:55:33 +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 z6G6-abwn9Qu; Fri, 1 Mar 2024 11:55:33 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id E0C91D99A42FF; Fri, 1 Mar 2024 11:55:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru E0C91D99A42FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1709283332; bh=f2qKsIAGkUNEVelOg7DTK/0b4IF/e+zG6QgMW3olvD4=; h=From:To:Date:Message-Id:MIME-Version; b=P8auQz5C6OaEzL92Wd4UVkrC0+agep5xnkw9WQbAvEflW8hYcBiV0bOPGTvWixe7R 5gxvNYDmZDMIDT39UZNaUeriACLVOP+LYwBzNwp2rfCUbIjLGIV4y+Gn9PkkJH1Er2 JUF5lJQmT3mMEr+/Q+tD7LNg94RH6EhR51r9IvJ99jPoMVABIFcQizUSbngm4T9xos YOlMDOS/3uc9mLjR6mQOjQb3qWpyRgPOrUpRCM0lhwhsDpkcZH8FPO5fhQU+YqsFOp sZn27iVdF2fI7cmW584/cJT+Vz4OzY87Bc1BK5LaXVEkH+8L44a/1Ao+xDCGi3r66n 9aqkPUQvTnBAg== 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 I9d5Qmb4AYe6; Fri, 1 Mar 2024 11:55:32 +0300 (MSK) Received: from ubuntu.localdomain (unknown [144.206.93.23]) by mail.rosalinux.ru (Postfix) with ESMTPSA id 97E4FD998EC3B; Fri, 1 Mar 2024 11:55:32 +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] drm/qxl: fix NULL dereference in qxl_add_mode Date: Fri, 1 Mar 2024 11:55:11 +0300 Message-Id: <20240301085511.23298-1-a.burakov@rosalinux.ru> X-Mailer: git-send-email 2.25.1 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 --- 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 *connec= tor, return 0; =20 mode =3D drm_cvt_mode(dev, width, height, 60, false, false, false); - if (preferred) + if (preferred && mode) mode->type |=3D DRM_MODE_TYPE_PREFERRED; + else + return 0; mode->hdisplay =3D width; mode->vdisplay =3D height; drm_mode_set_name(mode); --=20 2.25.1