Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2285082imm; Mon, 24 Sep 2018 01:23:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV623ythjg6xUwQpTF1oCqeX5CSLiKBGDUS+9MRUt6obR+jynYOoHBAb4fyy59iTXqV2T3HXl X-Received: by 2002:a17:902:6b4b:: with SMTP id g11-v6mr9284024plt.19.1537777416641; Mon, 24 Sep 2018 01:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537777416; cv=none; d=google.com; s=arc-20160816; b=GiQbyPIcYG9j00fsLaGrmiNKHoXweEhfZ2ah7k+Yk3SY3mU7WVDVtupCT5Xu/Kr+mB oBIynILQhZjhogu7PT99XPD14z38x7hm69b/BEWlDPjhXzA6xdU+acX0ngq4V3TtaXVT bdoIVfxnPHrWpU/2V/DzTd+iv6SCwSZ0rT6uN3bil9gQKoRDn5XEiMC8zC9Elfqq8ctm Lkof7FoxJx9CBP5K/EK4J58zEHXJUmI5/k2Qzj3hmki3pPKq5yyJItGlYTUnjNpwqqnE UWtD7Ex12bwIFkz60QBUFuibi0n94As0zGldhcD+4UF1lEZs/3coC1r9aoe1kMSC29JK cu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C1gJRhX9kcXYo+qobOGEZNI2c+EQHg1Y8CnwRzwKVVM=; b=OtWhn0nZNVEaUWYguP6tnHEIP4a/QpIAjpr50ZGYLpSyI0GsOLtMkC3R6Bj+yGesne MkKcRPEmD2jW81xbSvlw/3fTeypp39nOqjtyiHZltGk2BqUcrNzkqDHcHfhHgPGBCcP7 xbbS1chaxL0OtR9DYRK9E0QrZx6JBq1byAJK8xRyceVXlZOsectUe2z3Aal+vTo30kAX HdrfnJAoXqoAI2p4qR8ih+6GBakfvQ7LfU1bjMAvaf93sI8iXrWF7P7kkjkmESLc+kbB VwzABX8Q3ZIPPxHcZwv301mO0QxMDD7SE7rH9yhs/Kn80IkdG6q5DioBGlVQrgC2FOCt APGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B0uHdyuF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44-v6si7977215plb.506.2018.09.24.01.23.18; Mon, 24 Sep 2018 01:23:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B0uHdyuF; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727335AbeIXOV4 (ORCPT + 99 others); Mon, 24 Sep 2018 10:21:56 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37045 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726074AbeIXOV4 (ORCPT ); Mon, 24 Sep 2018 10:21:56 -0400 Received: by mail-qk1-f193.google.com with SMTP id c13-v6so10698752qkm.4 for ; Mon, 24 Sep 2018 01:21:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C1gJRhX9kcXYo+qobOGEZNI2c+EQHg1Y8CnwRzwKVVM=; b=B0uHdyuFyqcpqN1uozzGtANtWhdGVuqgSb4G36FRhv+RseAJyeRzpTt55lpReKE6Lz JsJ92+RNjC/ikkI31a56pLvPApRmAIre2UtHJcIL5jqkqPoARw7AkvSZaVQKK2FfO5rO ZfEJWe6KaBIsAW19wQIDM5Au7jUzHTFNDT8D4BkDMpoK/zfrOpx24x3oMThIZTxcrGe6 da06u4zXjp7i/M1fKG8DMEvhs2RacEu0fPyCXuPH2FabSvplboSMNaAAWAIT1TbMfB/N 014au0PnPlEiAknSIdeEiJLx63R3Es0IJZm00WHtziHOiGJEk85nur8EQp96um3LXTs4 Y/zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C1gJRhX9kcXYo+qobOGEZNI2c+EQHg1Y8CnwRzwKVVM=; b=JCQo1jpe5t0lMys8KDq9xSnGTD03TJqSHScIaxfai6MXYkqQneOnWDvG68+AchJicQ dCHqF9cRNTiWr/sI7CuiG2zvFxIZOYay9OebjI4tub3wDJl4kHDde6dkWbxEtxCFlAA8 GJCfz75/g+Uf6GKJu5cwzwfmB1dtu4wNZC4MxANdLWya5wp2mf0Sg5N/oRcMxlKIdFrj 9F6QcS7mANcf5pU+JlCUUf0ZZsgsQgq3C6baYoFvEE5MqBqPM9GG0iyHkPTTO5cu0e01 K8khLuX413ecFRh5Jwu8uMQWkj9KDKOlwMLiRQBJQYxhONTkDnsZ8dukLrNHrlIMcPn7 MSBQ== X-Gm-Message-State: ABuFfoixkooCXG/r1ZwyZ1sMpr3rcRDx3DXMHoarEDnyI4a75Txpix5u Oi1aBcvalULLqbjOwdNlIgcrCWX9jSdSCpqMgNyBRA== X-Received: by 2002:a37:dc41:: with SMTP id v62-v6mr4020262qki.109.1537777261484; Mon, 24 Sep 2018 01:21:01 -0700 (PDT) MIME-Version: 1.0 References: <20180920144904.24911-1-romain.izard.pro@gmail.com> <1537535934.15252.3.camel@suse.com> In-Reply-To: <1537535934.15252.3.camel@suse.com> From: Romain Izard Date: Mon, 24 Sep 2018 10:20:50 +0200 Message-ID: Subject: Re: [PATCH] usb: cdc_acm: Do not leak URB buffers To: Oliver Neukum Cc: Greg Kroah-Hartman , LKML , linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Best regards, -- Romain Izard