Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp959740ioo; Thu, 26 May 2022 20:35:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1ldPB/A1Qrp36oAI3HdNnD8pIcTCACwz2eKYcTs6XJ807E5aaQJjyLbEQq8BxJo5dGnx2 X-Received: by 2002:a17:907:3e94:b0:6fe:e7c0:94f1 with SMTP id hs20-20020a1709073e9400b006fee7c094f1mr20546798ejc.420.1653622516172; Thu, 26 May 2022 20:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653622516; cv=none; d=google.com; s=arc-20160816; b=upu3zgtEU8i461f8tvkBsFDFfHcnAh3956XJXq9jgFzAlarh5hhqDubLrZNrMnBIGM apiN3pSW8vV5w1xzQOjA2KbLh3Quf4bN436HrSdbxj25WldNQw/lVAlOkxJngVTsX5QL cr8ek35X8cbf7s5P2YzgBUei95ZqAOOGfSs1vVsYeidS+J2S7uLmlzrEucjl+KAF393E tfwkTNWEweUUJ1iY5VzZuEnwjgvgjENY0ODOLYSiMcJwCF+icYd4Zjl9gHS+pup68ekW s7qXw/rSXKCFSrwHHzo87U084j1XMr7+cSDLMd+SPUy/sLWW4n1AlIjhuSqoxS6y3QCQ MJIQ== 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=AvqraPVaNx9IsgiWCX1oOyE2W40ckH5pzehGnIS8mmQ=; b=gXKA5nwrdUnW34mM8nXCSexiDvnhyU5PzThZHD8132E0IbYwvK0awL2/rBE6u1iAzN Lh/kvA8ps0NEBYWo5uOKQNbdNlQexxbQHdreezvBXX1n8pzfYJUmZ4UUK0LK/kt6S8oy +bjFiOLp5jFikvTugsVseLyhtagAK2db7BwHqzSwmg/LxaOS5Sys04B4tdZ6qCI1LnVl gdVB2WUapAIvl6LedgfrXY2ucnEy3A3PLk9y7kAwXF55vLRHw7Q/VDfrQY4+6mDpDsyW UOY5RZgTT85izO0fgY/UHTSPxRQtaH3RLf+21oiEiAk8/pzDjZydB19l30fdEHnjdXKP sxdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Lg62DDh2; 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=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a50e68b000000b00426305c7d2csi3198726edm.608.2022.05.26.20.34.42; Thu, 26 May 2022 20:35:16 -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=@collabora.com header.s=mail header.b=Lg62DDh2; 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=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349648AbiEZXyj (ORCPT + 99 others); Thu, 26 May 2022 19:54:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349619AbiEZXyd (ORCPT ); Thu, 26 May 2022 19:54:33 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79221D6829; Thu, 26 May 2022 16:54:25 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 874411F409DA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1653609264; bh=S5lPIOkFBZ/pxkGf3spJfxaVtSGwy0y8jmdOsiAMgdc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg62DDh21vtmkdIS8xg6XG5/5n+/FkMQv6yZUvNboK4hEgCbL5z172KDGIXNi8qCW w23AGO/Wp1pfJUwN+TRwVvu/hKAD9bRftGl8r0EiZ8uelJoxeg5y6cREYkrk6mpKD2 BNpSZI58w/DauiFQ0rE30zrNr/LAkKkUR2ZSopplZ6eGAw5GgLEwIfKM6iknDVZ+n1 eLrn5re2tv478zMT5HSTum8cHePRcWFV0K7oZ0fG7bnZt9Ykcr+uYtRisDSVhOZHsL mD3woWmqFPrJRAtMV3SJHPWk7+lNthgUecjl23OO+1L9CpKIvpwJ7JS8oyFU+iu8gg LhuBMhFoETsVQ== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com Subject: [PATCH v6 05/22] drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling Date: Fri, 27 May 2022 02:50:23 +0300 Message-Id: <20220526235040.678984-6-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220526235040.678984-1-dmitry.osipenko@collabora.com> References: <20220526235040.678984-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 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 Reviewed-by: Emil Velikov 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..3d0c8d4d1c20 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_OR_ZERO(shmem->pages); + if (ret) { drm_gem_shmem_unpin(&bo->base); - return -EINVAL; + shmem->pages = NULL; + return ret; } if (use_dma_api) { -- 2.35.3