Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3024772rwb; Mon, 15 Aug 2022 16:22:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Re6OSDwltsTX/vrtvZZ9wdLE6CVBX2UF+X42zWlLNOO0q6ELSyIx4i/97WIhTAtmm4647 X-Received: by 2002:a05:6402:2b88:b0:43a:6c58:6c64 with SMTP id fj8-20020a0564022b8800b0043a6c586c64mr16573730edb.348.1660605766813; Mon, 15 Aug 2022 16:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605766; cv=none; d=google.com; s=arc-20160816; b=G8WXme2qjhPBGo8gx8NPzdt8mE34e900yDJVOtJVeD1xqU0lVBWqnCPQRgls8KAGXT hqAnOUd9GY1O7WwkSRtJIy3K1oKuKpzgKtwEbkEGzjomOSq/5ee6I1RI0DTK3rF4VKdI H6yidQV1pqeI98qeuBm2OGP5zO6NtBwF1jyL78PvpE7Wa9NUHeRdCfavssnMxzPujLDn Gkwcf4tJwh3AuupHV0wXxqxDfb5JagOH57lglO6lJKzVxgw9XQjyfvOOiJDHWVRNtLeQ roPFSb9vaJExi5THCO391ic1ojCcmP+g2zAGMAEAgQFX7eS0/gcstSS3+cnqctoo8dcm 3FiQ== 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=4eEc4pFh9Y2eTsWXHH2IBqoJYL6yWzZzqW85/wB30lE=; b=Csux6bhlT+8zIhXBfiyE4/MhlyZJs+Oi8qfS24xjItQ0xAzvBULYfJBBbZKHzt+joH P57zFn+hvB5UM6mNc9QFQTfXajx8GVj1jIqXsUtIK0rG49pxTJu+5RvZ9EjuJ7KpWITk MEUfYQxJspRstvOH82NGyPXJgJK4NZFuxXdritakPUze9+fPK/qXeqQe9WuzddaGRo+I ylrHY6lh3kI05BjJfagvhhRUD6NyL9/ShR2tGfS6BjhnZpyf6ZguCGhc8Q0jSLe2l7dA 2+6zlV5JiZezvJ+Jn2TzzvpCzLr/0Ud4qMNzOwN8mEU1degolJeABedZGsY/zbmI5CsB Ca5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="IN/vwRZR"; 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 x25-20020a50d619000000b0044300fd7587si8362270edi.364.2022.08.15.16.22.20; Mon, 15 Aug 2022 16:22:46 -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="IN/vwRZR"; 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 S244278AbiHOU6T (ORCPT + 99 others); Mon, 15 Aug 2022 16:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347018AbiHOU4N (ORCPT ); Mon, 15 Aug 2022 16:56:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1472DA8E; Mon, 15 Aug 2022 12:11:55 -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 3757A60BC2; Mon, 15 Aug 2022 19:11:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41571C433C1; Mon, 15 Aug 2022 19:11:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590714; bh=qd7DGm7gGOW9kfEJ46D2NiTS3ftZuyV6LqQZH+9ayTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IN/vwRZReM78KSPc4Nqn6idmUscBBNNR5TMiWhK/KRLHrlZTKb1AHLMz+jUGy+P0V 1zTj2kpY6Ptgc42v8yLi9l7br5gAuYUVY4MyvSH0z0xTc6bn00pAiMT3o5RmlDpMYR UyqLmsFSM4rCwD+v04UpxRtvz2+U9KmvW36Bvamw= 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.18 0330/1095] virtio-gpu: fix a missing check to avoid NULL dereference Date: Mon, 15 Aug 2022 19:55:29 +0200 Message-Id: <20220815180443.434668603@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 c708bab555c6..10f080060923 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -579,8 +579,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