Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp490135imm; Wed, 13 Jun 2018 03:55:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIAoxcj4hjaY3q47duiQFff9KnwkcZecBFnArfWvNb0HQtk+s7I3bqsK2GvMbWC7CT6wJRN X-Received: by 2002:a62:2091:: with SMTP id m17-v6mr4367980pfj.110.1528887332512; Wed, 13 Jun 2018 03:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528887332; cv=none; d=google.com; s=arc-20160816; b=zaiD980itc3Yjhf4Gbo55zgjvsQ+3oLuxsncZqq+mQ5Rdy+9AL6qVkMeiyP4gi/Bw5 R10aEWDbxBx/aAxzkqVpEGKEwHC3HBIJy+dPgmcmW3E8jEB3l/s0LcL9+wSjxYvU7CV+ xAL7x1pR1jQU4vihcLbj1uY3Ci8O6MEoayGlK0UA52ek+SuXZQJFkGjdCMsfI9LTN7Xf hFc7+q4wOixRVom7oDpc3SV9DaqnPU+c6Dpccbe4Il4yVvRtu1eWG9+7t0goBcCTn7ga 2oCLrSPx2EYy/p15qaID3o0yHET6IggShCCpqJzTb/SS+2KsKVW13BXv9GVPrZnlc/a7 ctag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:reply-to:arc-authentication-results; bh=Fp1eiF0vV5cJ0AFMKX9OcuZWFYWDlPf08xSQo3Lo950=; b=WxazuIYHy4kzrSAszzIGdqMcBJih2aGV6ow2wo4IfrZWfawUsEFPWolX9IZr99U/Uy Qh5GxGe0W2rmgLmB2HFPy3ix+rdTMM+9cyvD/xWs3pRBgjSqvG9gokn04mTzTYPY9Uua wNvhN3oShGndhnJY4ZLPqN4SSCLDLiSaligE7v43EC8jYmdFxnfN4o5E9Cqu68wkGw0W Tnqp1d3q5fydIBgEIIKHjvtKQG1BIRnXlgPjiz6xJfYYtoTsRmuMrWR96Oh6FjQCNmmx lNO9df1Qy/aKG7RwY80EBQVjYXPQ6Errg+Ol4zzVtdcDpYW3JPfOSscIn7NvFHoP45HW uwKw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 74-v6si2632352pfp.161.2018.06.13.03.55.18; Wed, 13 Jun 2018 03:55:32 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935252AbeFMKyv (ORCPT + 99 others); Wed, 13 Jun 2018 06:54:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56280 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934527AbeFMKyt (ORCPT ); Wed, 13 Jun 2018 06:54:49 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5DAsH4E102595 for ; Wed, 13 Jun 2018 06:54:49 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jk0b0mgef-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 13 Jun 2018 06:54:49 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 13 Jun 2018 11:54:46 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 13 Jun 2018 11:54:42 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5DAsfYQ27918356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 13 Jun 2018 10:54:41 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52B8DAE055; Wed, 13 Jun 2018 11:43:31 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7B2C3AE057; Wed, 13 Jun 2018 11:43:30 +0100 (BST) Received: from [9.152.224.92] (unknown [9.152.224.92]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 13 Jun 2018 11:43:30 +0100 (BST) Reply-To: pmorel@linux.ibm.com Subject: Re: [PATCH v5 04/13] s390: vfio-ap: base implementation of VFIO AP device driver To: Cornelia Huck Cc: Tony Krowiak , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com References: <1525705912-12815-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1525705912-12815-5-git-send-email-akrowiak@linux.vnet.ibm.com> <889b8d41-e08c-0eb5-2de0-a1d6669a03b3@linux.ibm.com> <20180613094812.1fd1846d.cohuck@redhat.com> From: Pierre Morel Date: Wed, 13 Jun 2018 12:54:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180613094812.1fd1846d.cohuck@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18061310-4275-0000-0000-0000028D4A41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061310-4276-0000-0000-000037947365 Message-Id: <41e7ccbd-f6f5-ba20-f236-7824c682994d@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-13_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806130122 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/2018 09:48, Cornelia Huck wrote: > On Wed, 13 Jun 2018 09:41:16 +0200 > Pierre Morel wrote: > >> On 07/05/2018 17:11, Tony Krowiak wrote: >>> Introduces a new AP device driver. This device driver >>> is built on the VFIO mediated device framework. The framework >>> provides sysfs interfaces that facilitate passthrough >>> access by guests to devices installed on the linux host. >> ...snip... >> >>> +static int vfio_ap_matrix_dev_create(void) >>> +{ >>> + int ret; >>> + >>> + vfio_ap_root_device = root_device_register(VFIO_AP_ROOT_NAME); >>> + >>> + if (IS_ERR(vfio_ap_root_device)) { >>> + ret = PTR_ERR(vfio_ap_root_device); >>> + goto done; >>> + } >>> + >>> + ap_matrix = kzalloc(sizeof(*ap_matrix), GFP_KERNEL); >>> + if (!ap_matrix) { >>> + ret = -ENOMEM; >>> + goto matrix_alloc_err; >>> + } >>> + >>> + ap_matrix->device.type = &vfio_ap_dev_type; >>> + dev_set_name(&ap_matrix->device, "%s", VFIO_AP_DEV_NAME); >>> + ap_matrix->device.parent = vfio_ap_root_device; >>> + ap_matrix->device.release = vfio_ap_matrix_dev_release; >>> + ap_matrix->device.driver = &vfio_ap_drv.driver; >>> + >>> + ret = device_register(&ap_matrix->device); >>> + if (ret) >>> + goto matrix_reg_err; >>> + >>> + goto done; >>> + >>> +matrix_reg_err: >>> + put_device(&ap_matrix->device); >> Did not see this before but here you certainly want to >> do a kfree and not a put_device. > No, this must not be a kfree. Once you've tried to register something > embedding a struct device with the driver core, you need to use > put_device, as another path may have acquired a reference, even if > registering ultimately failed. See the comment for device_register(). > IOW, the code is correct. learned something again :) , but still, a kfree is needed for the kzalloc. Does'nt it? > >> >> >>> + >>> +matrix_alloc_err: >>> + root_device_unregister(vfio_ap_root_device); >>> + >>> +done: >>> + return ret; >>> +} >>> + >>> +static void vfio_ap_matrix_dev_destroy(struct ap_matrix *ap_matrix) >>> +{ >>> + device_unregister(&ap_matrix->device); >>> + root_device_unregister(vfio_ap_root_device); >> Also here you need a kfree(ap_matrix) too . > Same here. > -- Pierre Morel Linux/KVM/QEMU in Böblingen - Germany