Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3692850ybh; Mon, 5 Aug 2019 23:41:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwumjCgYQVtIMkVQRVwICcRSjszxJdJ81jynuNBpycOGzESxgqY0SAS6VzHzJLzlqgpr18Y X-Received: by 2002:a63:5648:: with SMTP id g8mr1592197pgm.81.1565073681936; Mon, 05 Aug 2019 23:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565073681; cv=none; d=google.com; s=arc-20160816; b=t3aCtEF2nAeR/dYs6nPXRJn1t2u/2797BR4CMBol8SWSXi/iYEDXNQ/n0BgVVacH1l dpfg6wgTFOMMrI5DD/627H/DXQK272GkD0L485YUzh8WUnNDpoGpulp8IBx6NjMg3XV6 kkiD74QyDFZ2jEmya8io4aPdxWRDj+tPDkNvWSZPtzrUnoP2m8SGGUflqDEvTrLPZpB3 8UFhyi8sQKODCWY4/dFTx5T4ezuf40R54pAO/ylFqRvUdq0Lyw8xj2jmX6YLonsck7Vv lCp2S/hCS49njIr0yFbkHrsl2rfj++Piq8Qdcg6MctlSTTUebnqhKyRNpdp4UlR7KmqO 9IWg== 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=i5JEbuADeYI96ttIQvKsSDkNomqhdNEAwNdEpBi8ulU=; b=aU8FDC3KnFgH/G+HMbwqt9c4SgtG3Tq7kn/Cy4HR1Msn7+TfMyCXQo64Pz0d+rAOYB wugLxcirR/KgkN9V9gEoDonUSS/TMnDdGQ5EhtwN2WeijDQyeQtUi3HIqQCB9+l50b47 cGzfu3ZuRGKvxHdtDE0Ff7MghnoIyCW7PNvuYzeMWWWoiab1y30U61ffAbpOC3p6rmR6 e3RiK6MdcnLAfyTppXpe8FZSGlDGOQlnI3bbqQxxPJVbyyTT//d2sWkQ1dAV+xphpEWl 72m9ketWU0ls7t62VRdl9deNKeKLHkkxOqGnxMqu95vUPnm5egAnb4r/+0JjRlnEQSXi FQAQ== 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 v8si41632261plg.122.2019.08.05.23.41.06; Mon, 05 Aug 2019 23:41: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 S1731948AbfHFGk1 (ORCPT + 99 others); Tue, 6 Aug 2019 02:40:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:45668 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731918AbfHFGkZ (ORCPT ); Tue, 6 Aug 2019 02:40:25 -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 0D3E7B062; Tue, 6 Aug 2019 06:40:24 +0000 (UTC) Date: Tue, 06 Aug 2019 08:40:23 +0200 Message-ID: From: Takashi Iwai To: Wenwen Wang Cc: "moderated list:SOUND" , Thomas Gleixner , Greg Kroah-Hartman , Kate Stewart , Allison Randal , Jaroslav Kysela , Richard Fontana , Takashi Iwai , open list Subject: Re: [PATCH] ALSA: usb-audio: fix a memory leak bug In-Reply-To: References: 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 Tue, 06 Aug 2019 08:13:06 +0200, Wenwen Wang wrote: > > In add_new_ctl(), a mixer element structure is allocated through kzalloc() > and the pointer is saved to 'elem'. Later on, a new alsa control element is > created and added to this structure. In case the add process fails, i.e., > the return value of snd_usb_mixer_add_control() is less than 0, the > allocated structure is not freed, leading to a memory leak. > > To fix the above issue, free 'elem' before returning the error. > > Signed-off-by: Wenwen Wang It's a false-positive. snd_ctl_add() behaves differently from others, it releases the given kctl at the error. And in this case, elem already gets freed by kctl->private_free callback. thanks, Takashi