Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1630809ybv; Fri, 21 Feb 2020 00:37:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyiVKKtY5Jcou/2RGa6yXhoOuQzTJ/s4RUiqcHKRAbkXuGAY1gyjyqDS48Pkt0RyKe2zCZ3 X-Received: by 2002:a05:6830:1651:: with SMTP id h17mr25773725otr.167.1582274262106; Fri, 21 Feb 2020 00:37:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582274262; cv=none; d=google.com; s=arc-20160816; b=YJ7l9DiTJ2rjYdgWhJ/E+9lTIDBnExAtY4ZnxqVdqMriG93OckQS2Rouo/qyp/CORl DbUCh2AQPuOduoDhfF+nVzgjZ7q3u+W+Ajmh7PFMatI/uawoFV/DTnPgyvWDvwiBI6RB hF+XlYJ24LXzhxuQ9ivBkprE3sozs6eA+vhH9Vjs/AlTz/0p4ZJ4P4c1LWfUwK0qq4WZ U7kBtAIUIi8kBEwha8MNW0vDf4tMDxo8FWcubCvnW/4vbkzeqnCxGg/R61CsrCjxkLhr DZLc2DtINw0n4saPCqWAUCCEmOiXGTDlyoOelm0+2A/Kdmm8Ftth/P3uMAt4oK50gDo5 N89Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=nZPMKkDRpIygusMljWBR/rOUYIWd4dKR+JmAgMAgsbA=; b=dNT3hay2b4YjR59h5dMTLCVbv9GbpVxnNMzfNC5RTedRYKq07TH5soZluxchgdrh5N 0+UIIgjVo260ywsKUQL88aD+Fnz8iO3zOexHv23BUJsYIuonCEi5m71bjO4ZoacgXtic qQCjXmEpl4WKs4sHJCMXEzzFEdo5C10y987Q9CDT+efpd58TfM/GFR0Z43hVOE0Er1pX 1ZgD5Aol6kPKktKlRrW4EhUDIjewSDadilCK52shcLUt2Vfg5JlpVHCLyg6ELxipdqKY UWGqSD1TY5pBVfYWumCyuwcIQ2r8xPoCP2tdMYCA9xTsRz7jIcXwnOwhzevu11NeeoTp 0Vew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z2GvPJvR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si1090778otp.236.2020.02.21.00.37.30; Fri, 21 Feb 2020 00:37:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z2GvPJvR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732608AbgBUIf6 (ORCPT + 99 others); Fri, 21 Feb 2020 03:35:58 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29048 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731974AbgBUIGt (ORCPT ); Fri, 21 Feb 2020 03:06:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582272408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZPMKkDRpIygusMljWBR/rOUYIWd4dKR+JmAgMAgsbA=; b=Z2GvPJvRkWsfuiiAD27KB6TojxSjhRQp9S9Av5hbeOWTA4eru/Ntys8T8U3ZjjGUVGKFyo LK4BLomJMkfe1UkZOHpR15hsVBTaTZVlHPXsg0kARuVsP4OXebVj1B5visGXu4zEsUj1Hb 3Lks0tO/7IUluBqN0C2ELNogBuAfwuA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-db6s2tGWP_mUlg7iG2WDtg-1; Fri, 21 Feb 2020 03:06:47 -0500 X-MC-Unique: db6s2tGWP_mUlg7iG2WDtg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 247D0107ACCA; Fri, 21 Feb 2020 08:06:44 +0000 (UTC) Received: from [10.72.13.208] (ovpn-13-208.pek2.redhat.com [10.72.13.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id A64978B740; Fri, 21 Feb 2020 08:06:25 +0000 (UTC) Subject: Re: [PATCH V4 4/5] virtio: introduce a vDPA based transport To: Jason Gunthorpe Cc: "mst@redhat.com" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "tiwei.bie@intel.com" , "maxime.coquelin@redhat.com" , "cunming.liang@intel.com" , "zhihong.wang@intel.com" , "rob.miller@broadcom.com" , "xiao.w.wang@intel.com" , "haotian.wang@sifive.com" , "lingshan.zhu@intel.com" , "eperezma@redhat.com" , "lulu@redhat.com" , Parav Pandit , "kevin.tian@intel.com" , "stefanha@redhat.com" , "rdunlap@infradead.org" , "hch@infradead.org" , "aadam@redhat.com" , Jiri Pirko , Shahaf Shuler , "hanand@xilinx.com" , "mhabets@solarflare.com" References: <20200220061141.29390-1-jasowang@redhat.com> <20200220061141.29390-5-jasowang@redhat.com> <20200220151914.GW23930@mellanox.com> From: Jason Wang Message-ID: Date: Fri, 21 Feb 2020 16:06:24 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200220151914.GW23930@mellanox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/2/20 =E4=B8=8B=E5=8D=8811:19, Jason Gunthorpe wrote: > On Thu, Feb 20, 2020 at 02:11:40PM +0800, Jason Wang wrote: >> +static int virtio_vdpa_probe(struct vdpa_device *vdpa) >> +{ >> + const struct vdpa_config_ops *ops =3D vdpa->config; >> + struct virtio_vdpa_device *vd_dev; >> + int ret =3D -EINVAL; >> + >> + vd_dev =3D kzalloc(sizeof(*vd_dev), GFP_KERNEL); >> + if (!vd_dev) >> + return -ENOMEM; >> + >> + vd_dev->vdev.dev.parent =3D vdpa_get_dma_dev(vdpa); >> + vd_dev->vdev.dev.release =3D virtio_vdpa_release_dev; >> + vd_dev->vdev.config =3D &virtio_vdpa_config_ops; >> + vd_dev->vdpa =3D vdpa; >> + INIT_LIST_HEAD(&vd_dev->virtqueues); >> + spin_lock_init(&vd_dev->lock); >> + >> + vd_dev->vdev.id.device =3D ops->get_device_id(vdpa); >> + if (vd_dev->vdev.id.device =3D=3D 0) >> + goto err; >> + >> + vd_dev->vdev.id.vendor =3D ops->get_vendor_id(vdpa); >> + ret =3D register_virtio_device(&vd_dev->vdev); >> + if (ret) >> + goto err; > This error unwind is wrong. register_virtio_device() does > device_initialize() as it's first action. After that point error > unwind must be done with put_device() - particularly calling > kfree(vd_dev) after doing dev_set_name() leaks memory. Exactly. > > Looks like about half of the register_virtio_device() users did this > right, the others not. Perhaps you should fix them too... > > Jason Will do. Thanks >