Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3287324yba; Sun, 28 Apr 2019 22:38:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+I/3lFiYqXrGMq2/eu1kZ0cUE6iuo+6Nz+MQVMNutGt9YJTAz3AaPzORn6oAf2IrpI1vH X-Received: by 2002:a65:4302:: with SMTP id j2mr56542776pgq.291.1556516301916; Sun, 28 Apr 2019 22:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556516301; cv=none; d=google.com; s=arc-20160816; b=rdzuP9XItWyWY9LzffGcf74OPaMSqNfLL4CD4L+0jxfrfII4e/iKT4ZAY+4ZsKx4l/ hLeJw6VGX3kv+hYGrMuDmlfsrcdI8bUFZf8aVkBz/1+pyjVmUfeEc7tCAtXhAEYYXL08 F9H4FdwVQhOEC/2tpuOvXPmTbw9OjBgbzPicBaLeChQCTrmIPLhqlBdZVQvsrqslLar1 pj4Kn3bu3e/GmVD3f4+l3aL9bJJ0QIuKeOj7m4e0OFlcVJ8XmuVru+VlicA+IhEqVnD3 87d8lBeOb0N4iHDDU+uTE/J22A2ZvIcL7JqYBAHUk2NL6jOhszZMs+0S2nZkpAaHbtr9 cRNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date; bh=NgcW/USkGiLPCkw0Al+7RcAwsuoMWg80jFwCPE823pg=; b=yaEpr2MDaZdq43QnpgFqmnIk8mbKeRnyFsC6ZOvhzcaCeYFC7T+TefXGaGZwwisSpD S+hB9ELcHY9atW4oWVtj2uFrjkHSAFxwFJV9xmCC0NQmZ6eNBdqK6bRes8hzYj159pBf BWlAHiVSW+GKn4iOC9eON6WUNWGY9hbPoJM1BEOrQ2L5Li84LypFkiLEVmbmlJlpdf0r htbw82jH3a0HTdSXw03dYwSIGc37MnZS4iSPtVT9XGWbn6xfQaecwSM7iAXZWZXurcTJ zubDdymEhJkdEgJg2zCjW62B/6jLnN3Zveh/t0GGUbpS9P3vagbab6jiV1TK5yImAbux jzPw== 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 72si31950260plb.165.2019.04.28.22.38.06; Sun, 28 Apr 2019 22:38:21 -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 S1727279AbfD2Fgc (ORCPT + 99 others); Mon, 29 Apr 2019 01:36:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:43882 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725468AbfD2Fgb (ORCPT ); Mon, 29 Apr 2019 01:36:31 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A86C1AA71; Mon, 29 Apr 2019 05:36:30 +0000 (UTC) Date: Mon, 29 Apr 2019 07:36:29 +0200 Message-ID: From: Takashi Iwai To: "Wenwen Wang" Cc: "moderated list:SOUND" , "Kees Cook" , "Jaroslav Kysela" , "open list" Subject: Re: [PATCH] ALSA: usx2y: fix a memory leak bug In-Reply-To: References: <1556433754-3291-1-git-send-email-wang6495@umn.edu> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 28 Apr 2019 09:18:40 +0200, Takashi Iwai wrote: > > On Sun, 28 Apr 2019 08:42:32 +0200, > Wenwen Wang wrote: > > > > In usX2Y_In04_init(), a new urb is firstly created through usb_alloc_urb() > > and saved to 'usX2Y->In04urb'. Then, a buffer is allocated through > > kmalloc() and saved to 'usX2Y->In04Buf'. After the urb is initialized, a > > sanity check is performed for the endpoint in the urb by invoking > > usb_urb_ep_type_check(). If the check fails, the error code EINVAL will be > > returned. In that case, however, the created urb and the allocated buffer > > are not freed, leading to memory leaks. > > > > To fix the above issue, free the urb and the buffer if the check fails. > > > > Signed-off-by: Wenwen Wang > > Applied now, thanks. ... and looking at the code again, this patch turned out to be wrong. The in04 urb and transfer buffer are freed at card->private_free callback (snd_usX2Y_card_private_free()) later, so this patch would lead to double-free. I dropped the patch now. thanks, Takashi