From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11112CA0FFA for ; Tue, 5 Sep 2023 15:58:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229445AbjIEP6b (ORCPT ); Tue, 5 Sep 2023 11:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352171AbjIEFjv (ORCPT ); Tue, 5 Sep 2023 01:39:51 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84273CCB; Mon, 4 Sep 2023 22:39:43 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 439861F74D; Tue, 5 Sep 2023 05:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1693892382; h=from:from:reply-to: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=8Dxo+OTaBq3eaJaf69uSWntTxeRXuDZqHqC6jWUmxEs=; b=GJ5gLQGo/c4xD63vbFDV9o2v5C9POygISqIBxNv6pobO6k+mq1jQqbRenMs1h1kOsnA08q PwIFdACl4qo1XJZNVfdodzmGCZ4rCwI3zlYs0d55/2uK+k44sQWjdRJxDwP2aVZc/VCHQQ Hg+8l3cSvhBMfKGDLBygyd876yDoSNQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1693892382; h=from:from:reply-to: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=8Dxo+OTaBq3eaJaf69uSWntTxeRXuDZqHqC6jWUmxEs=; b=505Djafo3RJfsC+Yl1bcf8IS+MmCYBcc6dVF+fvsHqfm9b8KMqPO/GXe40XEY3ALkw+Rcu I/6L5oi/tV+gXkDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 197D0134B2; Tue, 5 Sep 2023 05:39:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2s5uBR6/9mRvNQAAMHmgww (envelope-from ); Tue, 05 Sep 2023 05:39:42 +0000 Date: Tue, 05 Sep 2023 07:39:41 +0200 Message-ID: <87edjdi3fm.wl-tiwai@suse.de> From: Takashi Iwai To: Christophe JAILLET Cc: Jaroslav Kysela , Takashi Iwai , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, alsa-devel@alsa-project.org Subject: Re: [PATCH] ALSA: usb-audio: Fix a potential memory leak in scarlett2_init_notify() In-Reply-To: <87ledmjak0.wl-tiwai@suse.de> References: <871qffmj2d.wl-tiwai@suse.de> <8cde2320-517f-3a38-8c3f-f807791c6c52@wanadoo.fr> <87sf7vkybk.wl-tiwai@suse.de> <87ledmjak0.wl-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 04 Sep 2023 16:08:15 +0200, Takashi Iwai wrote: > > On Sun, 03 Sep 2023 21:42:55 +0200, > Christophe JAILLET wrote: > > > > Le 03/09/2023 à 18:37, Takashi Iwai a écrit : > > > On Sun, 03 Sep 2023 17:04:47 +0200, > > ... > > For the start_input_streams() caller, this is fine, because the > > corresponding memory is kzalloc()'ed in start_input_streams() at some > > point, but I've not been able to check for snd_usb_midi_v2_open(). Oh I overlooked that point. Yes, it's a missing call, although the memory leaks as free_midi_urbs() is called also at the destructor, free_midi2_endpoint(), too. But it's definitely better to call at the error path, too. Will fix it up together and submit the proper fix patch. thanks, Takashi > > > > CJ > > > > > > > > --- a/sound/usb/midi2.c > > > +++ b/sound/usb/midi2.c > > > @@ -265,7 +265,7 @@ static void free_midi_urbs(struct snd_usb_midi2_endpoint *ep) > > > if (!ep) > > > return; > > > - for (i = 0; i < ep->num_urbs; ++i) { > > > + for (i = 0; i < NUM_URBS; ++i) { > > > ctx = &ep->urbs[i]; > > > if (!ctx->urb) > > > break; > > > > > > That was the intended behavior of free_midi_urbs(). > > > > > > > > > Takashi > > > > > >