From patchwork Thu Mar 2 17:28:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Mogalapalli X-Patchwork-Id: 63508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:7b8e:b0:9f:8c76:fea4 with SMTP id j14csp5856327dyk; Thu, 2 Mar 2023 09:32:39 -0800 (PST) X-Google-Smtp-Source: AK7set+znXml3B37Py7BlFsblZCDcg2Mn+UK2GqvAgIXdG+6OAEiTKCwWKy7q+rjsgQFhQAg4lJf X-Received: by 2002:a05:6a20:42a3:b0:cd:83b1:420d with SMTP id o35-20020a056a2042a300b000cd83b1420dmr12523434pzj.38.1677778358793; Thu, 02 Mar 2023 09:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677778358; cv=none; d=google.com; s=arc-20160816; b=JAxJ6F8/wReIvrdv30DF3n0bHoiq9IWJTgzvWAnK4kJtp1YEPPTa1DGSwJJbB/HU4r jsHn0bte2o0MQ15Me+PXBOHyjIzk/kBGdbb5DKNW5OdfBzXvT3wFjnAhpW38PoZ4w5u8 an8jA/eFB4ybnDcrv1UbHY6C5CbIWWSkunTvCjJ91xDJI7FKh91BtTAZL9KOQPcaF+KC b5DmZdXuzywGpfp/4vd7p6e6DaTaw/guRsPP4/QGpzR6N9QdS4jA1PQp3MrAt5asxfqB vvqAfVwLUyagKmJRl0zpA040VIJogVEsSOTa9kw3/LV8pvthuekK5d/yGW/CgVFH4b88 7U1w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=76hz/LoZrb9hKz2kKw8dK3i0sE3tDLtAmUawebTB45g=; b=EUWBDLezqr/l9MlFdNp5S6weoloZs7pIZ3sl856PvYa+SBP4JwYiEE8vfoqgTdqGt2 3pUsHG9D1O+g40qPfAES+87b3zB2Du8QIaAJIcWna7xnRl6kTAxzda+x3eRD10NhUVJt su0WvNsB9tEA5H9lS8payDbR22r7VsxU/rOp7STWRytVvj8Y2U1ipYPXm4bqyg7WDGvN veGhWBlCqiaeZ1FPra6DvMOYuVLJC63J7G1MiGFeUJB7FAKH52SBxC2ZrjhnTosGJT6q vTzS4xrOb+Mf5WHqpNt6xG+UBpeJ0LeSMNNYafwD7iSCblCrKuZVLM4LtovSsS5Jtb1K 6D9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=KhkHkaN+; 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=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd9-20020a056a00278900b005aa4d18a073si17012162pfb.259.2023.03.02.09.32.19; Thu, 02 Mar 2023 09:32:38 -0800 (PST) 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=@oracle.com header.s=corp-2022-7-12 header.b=KhkHkaN+; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbjCBR2h (ORCPT + 99 others); Thu, 2 Mar 2023 12:28:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjCBR2f (ORCPT ); Thu, 2 Mar 2023 12:28:35 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D36A3A859; Thu, 2 Mar 2023 09:28:28 -0800 (PST) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322HNOAc016779; Thu, 2 Mar 2023 17:28:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=76hz/LoZrb9hKz2kKw8dK3i0sE3tDLtAmUawebTB45g=; b=KhkHkaN+qY8ZQ4jEr3Lb4yDk4DpjRxLQKDInF18W39eb1V5LrLAg7s9GNRHWRSqH2dsw nmNQA4ibVP7QxFaWNfvvho5SHSBWkqAAY+hJOnIyKf0wEqlg/Zi0GQzLddQzrcMg8uia EetbPO4KZXMZCsGbYu6igddJ6lqHwCZ3tKCmy0qZuQO30PCT+KUT+MTD2TfN86gxao6/ 8MIkQRITakFgvpWALwN9dDCrugJeXsmWx2zvAJWXdG4Y/czhKWm5FQg2tLzV6rlSbmrx uLoH3Yv5CzFPZfMQW897ad3SeqYCO9MGuOuHDrTOzyrV3SkZCq3DQU9YpaAYBw/Ug065 MQ== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3nyb7wvk4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Mar 2023 17:28:21 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 322HBVE4004832; Thu, 2 Mar 2023 17:28:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ny8sanysx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 02 Mar 2023 17:28:19 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 322HR3ls035594; Thu, 2 Mar 2023 17:28:19 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3ny8sanyry-1; Thu, 02 Mar 2023 17:28:19 +0000 From: Harshit Mogalapalli To: dmitry.osipenko@collabora.com, stable@vger.kernel.org Cc: kraxel@redhat.com, linux-kernel@vger.kernel.org, emil.l.velikov@gmail.com, airlied@linux.ie, error27@gmail.com, gregkh@linuxfoundation.org, darren.kenny@oracle.com, vegard.nossum@oracle.com, Harshit Mogalapalli Subject: [PATCH 5.10.y] drm/virtio: Fix error code in virtio_gpu_object_shmem_init() Date: Thu, 2 Mar 2023 09:28:16 -0800 Message-Id: <20230302172816.3508816-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_11,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020150 X-Proofpoint-GUID: wF5R1rrLWcL1sa7LcLRQ-IXNUnEz6a0D X-Proofpoint-ORIG-GUID: wF5R1rrLWcL1sa7LcLRQ-IXNUnEz6a0D X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759277762394056938?= X-GMAIL-MSGID: =?utf-8?q?1759278120052138193?= In virtio_gpu_object_shmem_init() we are passing NULL to PTR_ERR, which is returning 0/success. Fix this by storing error value in 'ret' variable before assigning shmem->pages to NULL. Found using static analysis with Smatch. Fixes: 64b88afbd92f ("drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling") Signed-off-by: Harshit Mogalapalli Reviewed-by: Dmitry Osipenko --- Only compile tested. Upstream commit b5c9ed70d1a9 ("drm/virtio: Improve DMA API usage for shmem BOs") deleted this code, so this patch is not necessary in linux-6.1.y and linux-6.2.y. --- drivers/gpu/drm/virtio/virtgpu_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 168148686001..49fa59e09187 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -159,8 +159,9 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base); if (IS_ERR(shmem->pages)) { drm_gem_shmem_unpin(&bo->base.base); + ret = PTR_ERR(shmem->pages); shmem->pages = NULL; - return PTR_ERR(shmem->pages); + return ret; } if (use_dma_api) {