Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3081318rwb; Mon, 15 Aug 2022 17:39:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+GqOU/v9OcRLPrPRWwv0u75YbXsI5KF6+JPxZ42tqut/09Wt/c+3+a+EPB83qpuU1jlZP X-Received: by 2002:a05:6402:4441:b0:43d:5bcf:afa0 with SMTP id o1-20020a056402444100b0043d5bcfafa0mr16339032edb.91.1660610397527; Mon, 15 Aug 2022 17:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610397; cv=none; d=google.com; s=arc-20160816; b=Wvt80jKh4GZeHPqn3UB2wpNALOwpR3bbW/7qR4eMdWmr3te0XFXvPWHvPGzBbGQC3n TZwrl5TnYBxyqT1YWA0ApMw8FotefjKNSMjfEsQEukqkW2gZSYDDNHQlqY2ltYmiYLk6 9Q9HUX4biM1+EuWJrz6LXswzn+EkP1pDNrV+wBGQ/A0Wfq4fcSNTduwLaDGjT8R+6+w8 kkTBkPQV6NUo41h97aycGhhRZq9dirI7cv49gtj+bJMxXGgWiIh9nlqdmdVZ1RIPueXK oS7N786dQ3ol7RRUgJx2tmm/R23YiQNlzvCiNPdzVuSYbKgFwXhI8DYXOrb2s7vFdNih 9iaQ== 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=za8lCIOTr+7m4CtPqu4+WyFKZt3vA8qJvoASnRHtN/U=; b=Z/GJkrd4Qp+j8RKYGN52eMBZMmqzTNWBMJC04rtZ8rnYyGnWFISy3PC/1Vu1qfnHh1 oWQVzXuN3QysxWITO0Tk0YZtwjjpp5iYUQsMc4uCZtPBrRO4YlmwODkLZ6cf6J1ZxAM7 Hjw+TmWwhp2Ne6UfR6HaSdInoFcYrcsM6ahZ0kZN8a6nour0zQac0NThIYmpQIVXeyOs qPsY6i1/XISDWOWTsMd4GQRXsil1pD/t+Pv2DObRj6M9hBG0T9z+OLYJAfYDVXOeT8oN zCcsFHjqTd89Mh7a9Amf00QWJmwIuwczIsNrTr5Xj9R++Ivz7pY2VjnFyVGSDd61Y17p zo2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P+ERtCSG; 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 q20-20020a170906b29400b0072f1be0dff8si7120382ejz.133.2022.08.15.17.39.31; Mon, 15 Aug 2022 17:39:57 -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=P+ERtCSG; 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 S240889AbiHOX22 (ORCPT + 99 others); Mon, 15 Aug 2022 19:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353418AbiHOXWH (ORCPT ); Mon, 15 Aug 2022 19:22:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 220FC5F8F; Mon, 15 Aug 2022 13:05:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id B379560693; Mon, 15 Aug 2022 20:05:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEF61C433C1; Mon, 15 Aug 2022 20:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593917; bh=YcHOJyY6Ze1wflj+HVPwk8FDdUytNxdCp0psuhP8bfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+ERtCSGpTP9Jjx2YpPDp+xNPCmbIhKHp00r9MKuUoPdFAHSWsDjeTIYaXbyca665 RWd5eSU7vqGp6JdgDFcoZLG0x3i5nDmJGzJCC0Oi7M1hA+s/w0GBDAKt5cg9Sh0hJX L8yuTnPzj5R13IZ4rj9wS/L8kauBSLSjS7BlZIQo= 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.19 0348/1157] virtio-gpu: fix a missing check to avoid NULL dereference Date: Mon, 15 Aug 2022 19:55:04 +0200 Message-Id: <20220815180453.638153634@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 f8d83358d2a0..9b2702116f93 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -580,8 +580,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