Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp818006pxb; Tue, 12 Apr 2022 14:17:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymTRTrV0zLTP+mTkB7vP171YNWM8sDCRz7PgGWGN5+7AjvucbRKzrgl46WOnir08awt0IJ X-Received: by 2002:a17:902:f54f:b0:158:9e97:df03 with SMTP id h15-20020a170902f54f00b001589e97df03mr737705plf.141.1649798259849; Tue, 12 Apr 2022 14:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649798259; cv=none; d=google.com; s=arc-20160816; b=0Ey+4YpvUh3Nzo1CusKZkCMgR+W2su4rtMgIyt8u2tSxDs0J4IWdIpmJSZ/X48vpLJ AV8XOOocvABPYpQXweFaKLXkl1KKxolVeXgAhjWVniF0+32p/dJVe1opNUAcoPEljODa fBcV7Q/1H/ArunMG0NVBhKNwaAHtPlCv7fkoICSsHL4ucWwdn/ssRNJae03QiDTgE73o HzG6hhxz+4Jg+pcmPvPHK2mpU3RXHM4vbu7TNwzBSpE695adwFCQ0mA+X+6ZQ4+Hozoc Typr1vn1yTTPLMTe5zmZKzufynm1IL4ipZs29pEuLiqlp8eHebxNkBUgpQnL7i3U5PIj tV+w== 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=0Aq7DpXhzppkmcCe4wAqT49yKmH1I5k7ZLbxdgXTp9sYxUsPVU9BQKReyfxY+iLcLH VS5Vmchsvb4+pwO91vJ9sqr/crUiYHufb40sTaiXMfejhAgNI95KBTMx7A1+WHUDaHiU Mjnx2S7AHfo2InOEZNOeS3mfIwQ6l6V6C/tNY1jAq+cazFtcBiRx7E4Ifo8qKofjGQJZ iRH4SASquIwyX5FOzf2tJS+1J1ZeL3Zlh+oy+yCsWYFZzFcndj9FZ2ewxobkobK/5SPs ctG+3vkUScUYHkg48hnaiurbuGzBIVxV3+M8qbtbomchlrIMhQiTpVOH7+vbIKPY1kdx 13bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="f/wz4QYe"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id u2-20020a056a00098200b004fa3a8e008esi13505789pfg.325.2022.04.12.14.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:17:39 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="f/wz4QYe"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73836F55F9; Tue, 12 Apr 2022 13:31:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347975AbiDKWCy (ORCPT + 99 others); Mon, 11 Apr 2022 18:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350345AbiDKWCe (ORCPT ); Mon, 11 Apr 2022 18:02:34 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38C11C11 for ; Mon, 11 Apr 2022 15:00:19 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 851571F43C6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649714418; bh=wczZ5iN2wkFP7L3LjYkS8mg7jidJdoFxxHCwNVCzNBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/wz4QYeAT54TyX8ugUAgVaFjiArplVVjrM6JDXz0Xb5Mi99JrIQaSY/dmBLaVWKI hcxA6DRzd+X7uqSDvl7vJ8c7V08L/PS2Ud4jjuI9gFqU5/lUogfdh9yh7CUHranH1H 1kfn7EVZQMoSKCbsAtlOktc56qJabWOZ2yG25/Dg4TjlFxaM7ST68fmtV5fpD9maHj LmL0xtNLluOq1J3GdaYRVCADI1SfTFLyycdXKF+7xpJpeA65P+KwZdzKBfRf02Tn7N Qh+JKYYygG86h3uBx0b8pwzyAu/MAgrPgPPkiBPLIw5hMsa52dtkKldDhcCOBB+NCA aFeSzVMIqcwDg== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gustavo Padovan , Daniel Stone , virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v3 01/15] drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling Date: Tue, 12 Apr 2022 00:59:23 +0300 Message-Id: <20220411215937.281655-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411215937.281655-1-dmitry.osipenko@collabora.com> References: <20220411215937.281655-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 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