Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2892410pxb; Tue, 24 Aug 2021 10:01:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4Gz9/mSpijNOqNK2Y7iIxyXpcPkqfcd3EdzhUrpv89kA0ujFk32f8Up+Yk9zb5xU9Az8M X-Received: by 2002:aa7:d40f:: with SMTP id z15mr43989775edq.113.1629824463204; 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=DSp+xlNiTs0W2Oq3jSkp6Z+w+HoGm2cPyEBVcBrKSBk+gKk6qoMzD3jSgWVU+b4eiO C0xx29acnQIDaS5EpKER6GTgtZ/HX4ccrraZFpU34r3afZZt3n21VbdbntFVyXwrGjo/ cVTDK294NEn7EkRw921nSgTGnrDikTMdx/0wkrdkDQ5bLuJHvdVVX9J4ph5KAE0usQ/9 W2lEZrKyV7Ec3gZUGUOEvV4Nfuse2/Y32AbmXZr75qX1xWJIRjWKNygwb1O7H2t2v/76 1yfYLSfow3Z1ficGr9DiuslNnsYTflNktJ2a2Ow+GpBsqZlPt5QgLbSPWj4aUHLLjhay AANA== 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=9bqIlqLUArkEKeUSqoF2YCSWjgvcIw3L1lIdAkTNbF0=; b=xiuLH95eYy95kZyv59cI6rk+9UGiJrnQdFD6S6xH7AztBmmH4BS2bcBq2GftDN8JFw Kjg426vkz86l1CRM7+bTnwrU1mecLAlBrn2qnYAxvbIDO+x3uYVAQDBN9QDPzaMW2tB4 sBXu6U2jw+MqVE5f5nnfci7W8ovMq1Wzcd0A4iWJGBP1eaoeS20DcWMpmZOn9kOrcmf7 kTYOtURHepqtrjryOzEccLr8GWR2quq0s5tV8gbcMs2JnF+PRkVSzDWN+m2xzwh19USN cdyDKqgivetsdIZNLS4aKBQVRCyjNHZIU5B0alOxq927FZepcbhVX6mNsgUg+WkULp1G kYJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jp0VXJR6; 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 h13si659403edz.392.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=Jp0VXJR6; 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 S238865AbhHXQ7I (ORCPT + 99 others); Tue, 24 Aug 2021 12:59:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234982AbhHXQ5g (ORCPT ); Tue, 24 Aug 2021 12:57:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 217FE61452; Tue, 24 Aug 2021 16:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824210; bh=GW1cChix8yRQjWAtbGMQrsUfwA/OFHQv+8fKhDB2LZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jp0VXJR68Basz3hN3DgBTW4XU353RPrS8Xj/aWOs7Ou0WJOJ0owtNIxY6u5fFayLo 58wcca9eW9lxHkte30A70xkhD8Lexy9saR23cYOUS/6BEz1DN8E/3mQDGPZ4+X38wX 1w4RMwqaLMeK/yzg+weELys9EjOdTJ782HKfJF7Rc/meSJyKL2oIGum75KAEqNE26t ofVKS9HrerIWRrMx4oVFN1gzN1ybiRCj53agPFaH6iUldMuBzIDNbcK7zCe/sqI2rC yw7KguDQHzlV7G+GB0wPEMPblSPMrWO5x+IGm7nt84h+O+qq551UUXmI//YFMVM1f2 7LiOEcfcOjbUw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie Yongji , Dan Carpenter , "Michael S . Tsirkin" , Stefano Garzarella , Sasha Levin Subject: [PATCH 5.13 043/127] vdpa_sim: Fix return value check for vdpa_alloc_device() Date: Tue, 24 Aug 2021 12:54:43 -0400 Message-Id: <20210824165607.709387-44-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 2b847f21145d84e2e1dde99d3e2c00a5468f02e4 ] 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: 2c53d0f64c06 ("vdpasim: vDPA device simulator") Reported-by: Dan Carpenter Signed-off-by: Xie Yongji Link: https://lore.kernel.org/r/20210715080026.242-1-xieyongji@bytedance.com Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella Signed-off-by: Sasha Levin --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 98f793bc9376..26337ba42445 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -251,8 +251,10 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr) vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, dev_attr->name); - if (!vdpasim) + if (IS_ERR(vdpasim)) { + ret = PTR_ERR(vdpasim); goto err_alloc; + } vdpasim->dev_attr = *dev_attr; INIT_WORK(&vdpasim->work, dev_attr->work_fn); -- 2.30.2