Received: by 10.192.165.156 with SMTP id m28csp1709246imm; Tue, 17 Apr 2018 04:18:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+0EoCfO0wpifcGHfhsOG9O9Jd9Kayaa9yRzsvwYRDB6WghuPapSvbrQBDCjDswFlXTBaOq X-Received: by 10.99.62.201 with SMTP id l192mr1429070pga.318.1523963887091; Tue, 17 Apr 2018 04:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523963887; cv=none; d=google.com; s=arc-20160816; b=DTublTE/pA7pUNVjJHM3jBQavN4nc8wXqiSzIryqIFjDqTIFoA18sfc7RvhC8AvUAD t3r99ILl0Ixo8KudxeUYmaMiUcrSr09ZZVQYFxfkDcF0BzN9e9zWLHJRKrU/s1bsgQAt vIROoJlvqtItmdDbxNClO3QsXJr0DuwLGr0cnEDWqeZcGBgGRc5tPlvrxVHYwhAcUSDU Pxe1c4AXY7g0t+u9IFHxRDhxODqcipALvlzxBq4WODEerbpnFRRHsRNKvGyzwqcIIHnf gd+M10p8nSkSNA5/I3QUWpdkpJQnbLe8p+cBhVNQsfC8Qd+KE6fJoAL6yPhzL5tWERzx Nk2Q== 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:arc-authentication-results; bh=X5uklUq2xlZsEsFlbwzQ1Ni5/hppg6+kQ0ZaNyTRV5Y=; b=y56KhFFKWP95cCul5+FR2tIZtSkT7gLeuwMn1ELeCG1E98JAoeJWH7sz+Vz8okJn1J 2UviM4vgGEur6t034SFD4DPfmANXbx/4LbI9FNdwAxxXc2Gp3Y8xHo2f0S/y2PAuAMSp ezSWZM6q+GtoWyHuFKNXSD1Glc4KLECmlFePAY/Gi9HVEUVNuieLIVvkCKXzXPOQ5Nj5 HmU9yxtp92ovOIezrjhzVgwG0ZTEP/JR1QYO7hBxtSjahoHGZsB63kxRBJ9lqVbqCzGI +lockFkHQnbvfRJXPt4lVByCvzj1o7/9xf+qHo53hL+NVuDFM8dE3xtDE83zXnhD/OI8 Aq+w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a98-v6si2770999pla.239.2018.04.17.04.17.52; Tue, 17 Apr 2018 04:18:07 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbeDQLPz (ORCPT + 99 others); Tue, 17 Apr 2018 07:15:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:35320 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbeDQLPy (ORCPT ); Tue, 17 Apr 2018 07:15:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C783BAB36; Tue, 17 Apr 2018 11:15:52 +0000 (UTC) Subject: Re: [PATCH v2 4/5] ALSA: xen-front: Implement handling of shared buffers To: Oleksandr Andrushchenko , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com, perex@perex.cz, tiwai@suse.com Cc: Oleksandr Andrushchenko References: <20180416062453.24743-1-andr2000@gmail.com> <20180416062453.24743-5-andr2000@gmail.com> <6ab76dd7-ec6b-0756-5490-f5b5805998d6@suse.com> From: Juergen Gross Message-ID: <7abbbaa0-93c7-5c93-d653-ed5a04199f6e@suse.com> Date: Tue, 17 Apr 2018 13:15:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/04/18 11:22, Oleksandr Andrushchenko wrote: > On 04/16/2018 04:39 PM, Juergen Gross wrote: >> On 16/04/18 08:24, Oleksandr Andrushchenko wrote: >>> +static int alloc_int_buffers(struct xen_snd_front_shbuf *buf, >>> +                 int num_pages_dir, int num_pages_buffer, >>> +                 int num_grefs) >>> +{ >>> +    buf->grefs = kcalloc(num_grefs, sizeof(*buf->grefs), GFP_KERNEL); >>> +    if (!buf->grefs) >>> +        return -ENOMEM; >>> + >>> +    buf->directory = kcalloc(num_pages_dir, XEN_PAGE_SIZE, GFP_KERNEL); >>> +    if (!buf->directory) >>> +        goto fail; >>> + >>> +    buf->buffer_sz = num_pages_buffer * XEN_PAGE_SIZE; >>> +    buf->buffer = alloc_pages_exact(buf->buffer_sz, GFP_KERNEL); >>> +    if (!buf->buffer) >>> +        goto fail; >>> + >>> +    return 0; >>> + >>> +fail: >>> +    kfree(buf->grefs); >>> +    buf->grefs = NULL; >>> +    kfree(buf->directory); >> Why do you need to free those here? Shouldn't that be done via >> xen_snd_front_shbuf_free() in case of an error? > At this place we only allocate memory, but xen_snd_front_shbuf_free > will also try to gnttab_end_foreign_access if buf->grefs != NULL. Okay. Juergen