Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2455664imm; Mon, 24 Sep 2018 04:49:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV612VxGO4jXKStaOmzvjRSNwUcM3O4Xa9A2CryXwTPA2UJMs3n63F9YdTLt0TJqo5tlEfBiJ X-Received: by 2002:a63:7f55:: with SMTP id p21-v6mr9193725pgn.285.1537789770007; Mon, 24 Sep 2018 04:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537789769; cv=none; d=google.com; s=arc-20160816; b=pwoA3uj3EvDo7j0p+yEcshFWBVEUlOd60vkUPWymVg++TATGi5ozqXeyCFM7BQ+mpK N4DXdsRcDg7scfn4bu1iH47otReAQyK3puDyulaYidKHmZaGK9GbAR1UmZ8mwSV8dy5p D60YdhDpo8HXkNYI4V1B5msYp7BbJPPuvxuJYPY74f7se9RNMNtn2aGSlByfW9A3/NaP 0bJoEGbd9hZ6/yy7BuHA57SSbMxbCUmSEAxz1VBf35EhqlEfMUC/q6oG0NwqE5fROT8Z EttgEqrwvGMEg/f+kbBD6YOdFeir77DtilrNA77qb95Sp7q+14U8qOmBU5+6OHtXj7n6 BfyA== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=AFYOdLoVAManSdzGzg3Zp1gRyVpop9Gclc1uQEFc1DM=; b=DcxS4XapWZ9xVl0gKUxhfjQN5rg/LqQrtlpxOiYFf9S9+BtKDJXcKG9L2h222R5Nfh Tj6msdi9krHAzlL+vlO9lF1RGNCB7bZXJw96UDiWgW1GHamEl/e+fqS8tJCRu1mzxDJv MHdSQjv6898j+g74uNplKPPWvmDKnaD02/OfstruFP6MK5w9SfraBxBOF2seEiAuh6iy 0xxQU1qrDffU/IqSN8GDakdxw2gBz8Ieionr8cQ2X2oY11V0qWwUVzPvrLae5BzNY7RD OrtvMngPSJDrN6omvxCeeiy2apOR6t80tWSuTZaYMuqfgfuu/gQcKcUA79wUxvnXDlG5 X8Aw== 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 b124-v6si11343391pgc.45.2018.09.24.04.49.14; Mon, 24 Sep 2018 04:49:29 -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 S1728734AbeIXRiN (ORCPT + 99 others); Mon, 24 Sep 2018 13:38:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:60578 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728397AbeIXRiM (ORCPT ); Mon, 24 Sep 2018 13:38:12 -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 4D98DAD33; Mon, 24 Sep 2018 11:36:33 +0000 (UTC) Message-ID: <1537788480.22022.5.camel@suse.com> Subject: Re: [PATCH] usb: cdc_acm: Do not leak URB buffers From: Oliver Neukum To: Romain Izard Cc: Greg Kroah-Hartman , LKML , linux-usb@vger.kernel.org Date: Mon, 24 Sep 2018 13:28:00 +0200 In-Reply-To: References: <20180920144904.24911-1-romain.izard.pro@gmail.com> <1537535934.15252.3.camel@suse.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mo, 2018-09-24 at 10:20 +0200, Romain Izard wrote: > 2018-09-21 15:27 +0200, Oliver Neukum : > > > > On Do, 2018-09-20 at 16:49 +0200, Romain Izard wrote: > > > When the ACM TTY port is disconnected, the URBs it uses must be killed, > > > and then the buffers must be freed. Unfortunately a previous refactor > > > removed the code freeing the buffers because it looked extremely similar > > > to the code killing the URBs. > > > > > > As a result, there were many new leaks for each plug/unplug cycle of a > > > CDC-ACM device, that were detected by kmemleak. > > > > > > Restore the missing code, and the memory leak is removed. > > > > Try as i may, I don't see the difference. Could you put a comment exactly > > describing the issue into the code itself, lest this problem reappear? > > > > The critical point is that on shutdown, the URBs need to be killed with > usb_kill_urb, and then released with usb_free_urb. > > As the code for iterating on all allocated URBs and the parameters are the > same for both functions, which also have the same length, the difference is > visually subtle. But conceptually, it is not subtle at all. > > I believe that this does not need a comment. Damn. I am blind. Regards Oliver