From patchwork Tue Mar 8 13:17:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12773808 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01363C433EF for ; Tue, 8 Mar 2022 13:17:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 477FE10E558; Tue, 8 Mar 2022 13:17:43 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id E295910E4AB for ; Tue, 8 Mar 2022 13:17:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id BE0921F4404A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646745458; bh=x9ELuT5l87DnnSxAfWp7rgapLQDyu7nCQiypyxue8IM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AisYgY0SCcQ5uduxHtXdKUR2x0DoQxIo226widUi6WSmtBN1xj8h9SZTrrSUfiGIy llAL/4sMgykVk4nZLHf0mtj2emCXySfJQJSXNdeOSfHAtasXicNewl/AONMV5ZyFP2 Mh8GEjMu2Dtjv/rFeFOqc794iaNlOJdOg0fwO5xwSDifSptRzZPvUpiGhUnJYySVq9 jhUFKIhW/D/Go75+oMcrGP80IruArXJEuMdnUPMbwFRA/v1mrp1aU1jdg9GjCJqT7G i6szm0wpV/RBuzl6mjP+++y/La8Ogbyse7wLBDrktUDEVAmISM68uVLMUulwt5gHUO rFOjfwWn3X6iA== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny Subject: [PATCH v1 1/5] drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling Date: Tue, 8 Mar 2022 16:17:21 +0300 Message-Id: <20220308131725.60607-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220308131725.60607-1-dmitry.osipenko@collabora.com> References: <20220308131725.60607-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomeu Vizoso , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Gustavo Padovan , dri-devel@lists.freedesktop.org, Dmitry Osipenko Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_gem_shmem_get_sg_table() never ever returned NULL on error. Correct the error handling to avoid crash on OOM. Cc: stable@vger.kernel.org Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_object.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index f293e6ad52da..bea7806a3ae3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -168,9 +168,11 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, * since virtio_gpu doesn't support dma-buf import from other devices. */ shmem->pages = drm_gem_shmem_get_sg_table(&bo->base); - if (!shmem->pages) { + ret = PTR_ERR(shmem->pages); + if (ret) { drm_gem_shmem_unpin(&bo->base); - return -EINVAL; + shmem->pages = NULL; + return ret; } if (use_dma_api) {