Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1857395rwb; Fri, 19 Aug 2022 10:32:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5MWFA1zz6Gp613D+XOLjy8p8zo1qoUwz61Jy5dBC/owc2HlwDMBUxDgcpXDNEYrTj3aK4T X-Received: by 2002:a17:90a:c782:b0:1f7:a4ed:11a1 with SMTP id gn2-20020a17090ac78200b001f7a4ed11a1mr9767153pjb.12.1660930326104; Fri, 19 Aug 2022 10:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930326; cv=none; d=google.com; s=arc-20160816; b=CYA0dNqQ+awaZ8tCGFlto2X7ZV+JUtaLBDKRweWcmCJXGmjtOkhyo82scmmEkoeENF 60eAS6/qGpbGMueCg0WNMwePQqmMpHMJ7uPzhoT7BBs5qOHDUQjnpn2P8p6KFDvxy1Jf PMmtrs7Y76CQJhzCX+C3ntbB0bXrrwdLA8vIuzfWUD8HCpBPLqzj7TXKHbIgzF51RIRz q5Lc+BV2RTXyRZOG7natdWqAkKxErrmECickYkn7dnPKoBb2YbhmEhr9poELptY/7ZEP MmdTTzgl6a/8rgqdGGGiK7iAaGIUo+yw498N0N3l8Wsq8m4gDFet+HxHGACsddZvtSyg 7g6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JauU9dRjzRe/zp5mFINLHFHErjInBtonBr5EbqZ/K1k=; b=YmIjT3Z1uwOMWpINTBJWGvUYfHtycuMBXW2YF61mL70M8dFK9SXkQVFrUNrSV5FL9H wt+YsbQLqOBlh4cODmcvUyZNnXLEijQnE9x4mGvUUazomqXR4C35QURCyS88tf2cc7vJ SsoogoJmCVuhH1t89tFw1N1tPTfWMwGetZUIUM2/v1QO1jo2f64whMxsAkb75PoHkOLs HJe1ooHQHAODGHYB5YWXvqWaPOaAaiiST83sHJwmvZLk3ZeDDtuCUE8zSPoY/yb7TxV2 0F24YScNdSGLt1akxTDOMUNAneOJeBVF/R7HbmEQq2XvE9ZwTuKP83bBMNxf/cybCXIe Tryg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KBK3gmv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902d2ce00b00153b2d16667si1058466plc.623.2022.08.19.10.31.55; Fri, 19 Aug 2022 10:32:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KBK3gmv4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351370AbiHSQHG (ORCPT + 99 others); Fri, 19 Aug 2022 12:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351643AbiHSQCS (ORCPT ); Fri, 19 Aug 2022 12:02:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1FCD34FF; Fri, 19 Aug 2022 08:54:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B42D8B82816; Fri, 19 Aug 2022 15:54:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FC43C433C1; Fri, 19 Aug 2022 15:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924441; bh=23YCPuFIHeZ1p8ilG4guZVDo1C84SgFeajMVaE7FK1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBK3gmv4Y424XILo4HEmvUJ3cSgR2G8lBmwIV5QMEUame6vixiahwSKqH9cNPUZOu 1XvUUBEgTQC/d/epMjd/BdGD5pi7lo/n1PweChCTGnFNTh96AsEsrpYTO7BJuNpM1n rLqaxfHB+GT+YOXKCE7DqJumqqA8zPbUSK2p9DHE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Chia-I Wu , Gerd Hoffmann , Sasha Levin Subject: [PATCH 5.10 171/545] virtio-gpu: fix a missing check to avoid NULL dereference Date: Fri, 19 Aug 2022 17:39:01 +0200 Message-Id: <20220819153837.003735650@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaomeng Tong [ Upstream commit bd63f11f4c3c46afec07d821f74736161ff6e526 ] 'cache_ent' could be set NULL inside virtio_gpu_cmd_get_capset() and it will lead to a NULL dereference by a lately use of it (i.e., ptr = cache_ent->caps_cache). Fix it with a NULL check. Fixes: 62fb7a5e10962 ("virtio-gpu: add 3d/virgl support") Signed-off-by: Xiaomeng Tong Reviewed-by: Chia-I Wu Link: http://patchwork.freedesktop.org/patch/msgid/20220327050945.1614-1-xiam0nd.tong@gmail.com [ kraxel: minor codestyle fixup ] Signed-off-by: Gerd Hoffmann Signed-off-by: Sasha Levin --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index c8da7adc6b30..33b8ebab178a 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -470,8 +470,10 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, spin_unlock(&vgdev->display_info_lock); /* not in cache - need to talk to hw */ - virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver, - &cache_ent); + ret = virtio_gpu_cmd_get_capset(vgdev, found_valid, args->cap_set_ver, + &cache_ent); + if (ret) + return ret; virtio_gpu_notify(vgdev); copy_exit: -- 2.35.1