Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3511919pxp; Tue, 8 Mar 2022 16:18:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpr9q/wUFLY2+gyqq+CbFzOjIsFQ68WHagpth2fSDsm4faB/icAhNhJ+Ar3YLOyky/RJYV X-Received: by 2002:a63:ce48:0:b0:373:ac94:f489 with SMTP id r8-20020a63ce48000000b00373ac94f489mr16509365pgi.622.1646785103224; Tue, 08 Mar 2022 16:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646785103; cv=none; d=google.com; s=arc-20160816; b=E0cC/YxstYmLOgnriEq0J0Wjh/Ri41U5rWCOG5PEEiCj/nWHuQ2GdOvlJxDUOnuJLJ DyUKUUCfIPuaYjHWQ8G2yXJ9smxsnfSx/BD6z0fZsUIPnVDrc+lWxxEtXbfS0FgOBRgP RZ1T/bVCDa4ZHJ25ldYlqscnYfuj9GAH3vEPdoN8jF+BkOJz7AhDHxW3DOfMkZ7MF5KZ iEUpDGllCwMgotHcH1AphONTvhOFmUIzMzuRD6DZZbAWDEj0BHXJlicRMtpEmEb1Lw0l mES0jRCwQlObnscFRK5Hbl83Z5OamPjZAw95sKMYFGLT5JV7h8zsxaA2f7DAr3R3a551 hSjA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FWF8ltBNxI7IQTMwZHDs7bv1T4eQYdN1SF8sPFaqCbA=; b=LhzhXXJ2pyxAEQofw2c5AIkHc8QpxJf5Qe9V1Ulio3ov/UoqfOWCg34Sl3qlsGc6FR sJ9J75ioCaoYInNzi63JzZuyOHd7MdhENUvXYNlhbvJTyMqiAqSqr5AgjCmVtbwp3Thq muG3QlYcYqypJ902bBTN+HCUfpTbwHhGyDHcuGTAHZwALfapkHtOk72As6UBVWHxJR/n w2zqrRdhrHwGLOytfBnA6AAgpW9dcMOSC4zQtHILLrwK845fodVfIZFzXm89GevYuoWT K9watFObrkoWpnlt83ZD7O41tk2n1W/eYl76YF4GI9V1QmrXA3Lh1M42btLiYnimPJgQ 3G4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AisYgY0S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q20-20020a63f954000000b00378ef4d9a8fsi313733pgk.415.2022.03.08.16.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 16:18:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=AisYgY0S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53FA3C4848; Tue, 8 Mar 2022 15:44:04 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347097AbiCHNSn (ORCPT + 99 others); Tue, 8 Mar 2022 08:18:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347094AbiCHNSi (ORCPT ); Tue, 8 Mar 2022 08:18:38 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECCD3D68 for ; Tue, 8 Mar 2022 05:17:40 -0800 (PST) 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 Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gustavo Padovan , Daniel Stone , Tomeu Vizoso , virtualization@lists.linux-foundation.org, Dmitry Osipenko 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 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) { -- 2.35.1