Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2892413pxb; Tue, 24 Aug 2021 10:01:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1mho0XJM2P+I+BdRnvwaXat3/LGSVbWBSImXspn/NblkdemkgeJ4De5G7OIsqCcVVgRy2 X-Received: by 2002:aa7:ce87:: with SMTP id y7mr44222167edv.306.1629824463231; Tue, 24 Aug 2021 10:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824463; cv=none; d=google.com; s=arc-20160816; b=BzBh7EbjrQkMaBCcCojzgDa3lvi/8SE2yBMcN7mlzo5PxKP7pvufZz4hUabgsAg3S3 Uj6vBJtq6GCgH9ulzo0bKyNEkbNDV7WPWtJjSyM2BjmRNbs2bWV6A/CDAoWlrwfyRuV0 ShfNGkVmeWJoz5vr0nzF4yKuSwhOWrHLOTHZg9QNxHPpFCQiKzZ3Jmt7Hmkf23CmIHXX 7P4cLwypMgsZ7vu8PtvRohjyNkQEckjbdzYLCseN6LFt7gf6NQ0wmKyM+8GbNAafXfx5 n8JgWIerUeGU5QmQH44AwhgHM09vqe6mugH6ZfIHWiTYwgxyS6ACncWFByAx7xlzwDdh +TOQ== 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=aLltfyF480qWh5sC79CXWszhygsn0YttsL/pU7zPsHk=; b=GqBaWDQdL121bTZh2EqWMSipSV8puFxKqhqeXSeOcYm/qnoQuTD1ZWQKHTnBKZjiii WROk+zuOncilIf9AOYGgg9bVAVjxLIdIyztAeKAvZIOte0wehxFMR42K8VTMD4aYexC+ /K4RYHGW3qp2kjsca4+znNgTv8QqAtDAWGFs0iYu+yXZbwg8l/zofoEHpbSiaoS4G3V6 ZQ6Ev6brr7BJyssfi5/x1V7A0pA85Mbo1s3hEutnQsdhyFQwNmgs/HohzWifyXBAkCQl sD+or7ndNNdXMHB1zd+LbS3FHcQ8dxFrjK3h99q6DImKvvCPGeKfvXE32MDipRG03HQ3 RPyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PTIfTicR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si467033edt.337.2021.08.24.10.00.39; Tue, 24 Aug 2021 10:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PTIfTicR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235347AbhHXQ7L (ORCPT + 99 others); Tue, 24 Aug 2021 12:59:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbhHXQ5h (ORCPT ); Tue, 24 Aug 2021 12:57:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3078B61414; Tue, 24 Aug 2021 16:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824212; bh=aUFHNpRV7mY+71E2wirnUi9kGGYnChRWtQHqWCR75OI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PTIfTicRkeZ0I0DnpCvxGZF56nHeEidywVHOEsnxL/waN2XzeBIDrEBQZ0mdB4dIH mfUP9t8CvKM/gcWChlu4sDS5LYq053MYmPrx61If+AxouvsTZYu/3U9b5CpI/i837u gpLrSTag9CN4MVkrspKOhyNcfD9OXDJtdmdNap43RUphWAiSyzRHwOjM7ZQofqVVku 8Q9b/rx2YD/5ZHRlTWYoNIALSdABsNeygzWwQZujomJcp9jgHCvZRXnGSpoTrdnYB9 Z7zC5Km2PJ/D9Dp47cl0kgtcrNAuBZ1GtpSLrVHxJIgj9TRzwOoVvIPQMefHeiRFPm f4czKlsYtHqrg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie Yongji , Dan Carpenter , "Michael S . Tsirkin" , Jason Wang , Stefano Garzarella , Sasha Levin Subject: [PATCH 5.13 044/127] vp_vdpa: Fix return value check for vdpa_alloc_device() Date: Tue, 24 Aug 2021 12:54:44 -0400 Message-Id: <20210824165607.709387-45-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165607.709387-1-sashal@kernel.org> References: <20210824165607.709387-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.13.13-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.13.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.13.13-rc1 X-KernelTest-Deadline: 2021-08-26T16:55+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie Yongji [ Upstream commit 9632e78e82648aa98340df78eab9106f63da151e ] The vdpa_alloc_device() returns an error pointer upon failure, not NULL. To handle the failure correctly, this replaces NULL check with IS_ERR() check and propagate the error upwards. Fixes: 64b9f64f80a6 ("vdpa: introduce virtio pci driver") Reported-by: Dan Carpenter Signed-off-by: Xie Yongji Link: https://lore.kernel.org/r/20210715080026.242-2-xieyongji@bytedance.com Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Signed-off-by: Sasha Levin --- drivers/vdpa/virtio_pci/vp_vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/virtio_pci/vp_vdpa.c b/drivers/vdpa/virtio_pci/vp_vdpa.c index 9145e0624565..54b313e4e63f 100644 --- a/drivers/vdpa/virtio_pci/vp_vdpa.c +++ b/drivers/vdpa/virtio_pci/vp_vdpa.c @@ -400,9 +400,9 @@ static int vp_vdpa_probe(struct pci_dev *pdev, const struct pci_device_id *id) vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa, dev, &vp_vdpa_ops, NULL); - if (vp_vdpa == NULL) { + if (IS_ERR(vp_vdpa)) { dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n"); - return -ENOMEM; + return PTR_ERR(vp_vdpa); } mdev = &vp_vdpa->mdev; -- 2.30.2