Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2734798pxb; Mon, 25 Apr 2022 00:52:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo0uQZDwptE+cyodgp2GWMOtWnFC/Ges74En1kNkys2EwGoHld7TOa8nqQQEFIBnKFsNp+ X-Received: by 2002:a17:907:6ea5:b0:6ef:f593:5cce with SMTP id sh37-20020a1709076ea500b006eff5935ccemr14920847ejc.182.1650873163286; Mon, 25 Apr 2022 00:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650873163; cv=none; d=google.com; s=arc-20160816; b=IGStCSxepbfErMrZZ0HtIiYtRS0P9pW+TRNYi6spGinZ69zUCeXLg+FDkBdGEFIUEX y9V16A7EZxaOqQ2yhOTbHaQlR+/J+fLm7r/Ukm9uyUu2om65fjm5DamKw5WzKXiSI4FY 2CMqTF0/ZtTZk4CZ0+T1V/6y7D2TfxrP7nQNyjiG2NVq/cI+pcxVL2hkQ5JnDe2vXPFf Qi3p5dXvDro6bZSzpLCZZtYjiuCU8O1xBiUMffTzkvKc85WUPrs/4q/sMA4VI9JdAGTZ ahNqjbDYHs97IfWg3ipukJwZ2qWIK7AIpOcZhpM10K6A16tZbZwi0T/OalAoLiNqc4ew dTGQ== 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=mxg/RAFcTT/1oo6Fu+qzFjxOToHNaj9RCY4Rxnr1jMg=; b=UW+YQXKuzm+VrC7eA0sURMhXMpcdBgjP7JSgi3g+hwKtH5mbnQEA7BBiHDS5npegls RIfScnqRFQdJUuc00BmzwWsqFT4YvuuqUKkULjsXLFFgC31ipjZEm8Z6leCprY5trJe+ +rXO2mWLgBp3TriFT6aL7WSpEFhkZgzv/lVjEacrxtcOPowKAdgpgc2CcS/tm1Om9BDb uJDj5Q/WTObw1CbSIPaOcjK4RvOFymaC6+iLlXGq3wcpRYQ0ZpRiTdvdieT+TaRxQWrl ocWq83E5VDEQ49xndns5ECLw0cZiZikigP+guJkcQO3prkFD/vejvYqwkrFgZOQTkS0T In1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=B9z4s57H; 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 fy19-20020a1709069f1300b006e89f4793e2si2153045ejc.71.2022.04.25.00.52.19; Mon, 25 Apr 2022 00:52:43 -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=B9z4s57H; 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 S237707AbiDXTIE (ORCPT + 99 others); Sun, 24 Apr 2022 15:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237628AbiDXTHl (ORCPT ); Sun, 24 Apr 2022 15:07:41 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993D013976C for ; Sun, 24 Apr 2022 12:04:38 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 67F8D1F44DAC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650827077; bh=wczZ5iN2wkFP7L3LjYkS8mg7jidJdoFxxHCwNVCzNBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B9z4s57HSgTTIa5kF6gzsveMS213uPtrxM9AN1Fzt0dUw9pOu2XtDzxZqXozVmCVv I/9nDHGHOVtWfTUmVe+6hpPSrMmNJYnWXkCMIftUQ8lUkANQyJWf+CzEar2snn8VS+ EtaPzIbmp4O2PWMUWc2RvV2hDJgGiCkwhxEBnsK59czdT4UrtBVoDHGtW/uwsh+8XC h2/TNZBzq+WN1z7F8QJYXB40HofVd4zShr6whn7O5LAdlGgeS5IBrb8yc8dWeSnNYu 9//eXFWQnFyq826ybiY9J0aFNM6dUIL8zk/3DY3aM23tAInJwdMyxgbKW39Wq8E1IM 6irCi+frl37EA== 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?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v5 02/17] drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling Date: Sun, 24 Apr 2022 22:04:09 +0300 Message-Id: <20220424190424.540501-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220424190424.540501-1-dmitry.osipenko@collabora.com> References: <20220424190424.540501-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, UNPARSEABLE_RELAY,URIBL_BLOCKED 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.1