Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp751641ybl; Fri, 30 Aug 2019 06:42:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+ql0qh6PlUAiXyPp59AR16JMjsP8Fiknq/WwOmHgEQEeqGC5m8akvy9HDc+x3sQZwx+Nm X-Received: by 2002:a63:1f1b:: with SMTP id f27mr12910661pgf.233.1567172525484; Fri, 30 Aug 2019 06:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567172525; cv=none; d=google.com; s=arc-20160816; b=KSTsK4lsWjJrRfeAjUaa519QcrIV+QdHZOBNoTCGgdJCIUYmJ5K0AmYCgrTo5ltHrz 1uL8UIfTDoJyrIc3dEzFD9v4XWbr4FmaQ4adD3x57wx5wb2FU9auPZYpkJpUP7l10QbY N1Z5/sp8YEMrVsMeTIvaOpTDPE+njXf8dUdgTzzl+FK8gnFiQ23PMYVufaXQxhpqktMl 6/WNThlXeEXgtuMNJ6d0NKCTdFjpNshEY5tYU8Wad4JhhmpqX7ecWRtwsOIHGLZQhjJ2 v5JyDwtGak3GDe52w/GlrohhqKPLEVN7VW3NiAOMZux6nKQBFYxvQLdg40ubdYZzkRtN c45A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=VqfJAcNhyfcKIPqBa7IzNXjxVRDnLxfxWe4FrkQALmM=; b=K+zsc/1nIuqN93IvmgDL+SPqiIOhWm/D1qS5kEvJ+ywDE1Lkpxe7d1jlEgdt9xqNiR nWpo75Ke/msTGVO7F5VtlU1nlyWrOxlftutXXhoqS8EbVlK1XyFl0Rrk9WBJFXLD22TQ q3Xm/rNGO+6OOcAkcudUHzOz217wSqX7+g5bBzDEuPNG0zqYBElljjmq94pTdnLTuctK QPtmwOBiBZ8ZnerPVGE1JaWPMZ/YkhZ4pVtzWcpSUOKT4PbPCIljzrzEm7WzkRUMCPaH zIjXD725sZNbwHwpps4U4EvLHvILNBB/EUTHWFaENpBRn1aOcWjYpMWsjA6ccDmwW/lI rZwA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s3si4492376pgq.392.2019.08.30.06.41.48; Fri, 30 Aug 2019 06:42:05 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727999AbfH3Nik (ORCPT + 99 others); Fri, 30 Aug 2019 09:38:40 -0400 Received: from mga04.intel.com ([192.55.52.120]:61411 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727455AbfH3Nik (ORCPT ); Fri, 30 Aug 2019 09:38:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2019 06:38:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,447,1559545200"; d="scan'208";a="181207600" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.170]) ([10.237.72.170]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2019 06:38:37 -0700 Subject: Re: [PATCH] xhci: fix memleak on setup address fails. To: Ikjoon Jang Cc: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190811082259.48176-1-ikjn@chromium.org> <5883d03d-31c4-206a-26c1-ca641dbf845c@linux.intel.com> From: Mathias Nyman Message-ID: Date: Fri, 30 Aug 2019 16:40:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.8.2019 9.41, Ikjoon Jang wrote: > On Wed, Aug 14, 2019 at 9:57 PM Mathias Nyman > wrote: >> >> On 11.8.2019 11.22, Ikjoon Jang wrote: >>> Xhci re-enables a slot on transaction error in set_address using >>> xhci_disable_slot() + xhci_alloc_dev(). >>> >>> But in this case, xhci_alloc_dev() creates debugfs entries upon an >>> existing device without cleaning up old entries, thus memory leaks. >>> >>> So this patch simply moves calling xhci_debugfs_free_dev() from >>> xhci_free_dev() to xhci_disable_slot(). >>> >> >> Othwerwise this looks good, but xhci_alloc_dev() will call xhci_disable_slot() >> in some failure cases before the slot debugfs entry is created. >> >> In these cases xhci_debugfs_remove_slot() will be called without >> xhci_debugfs_create_slot() ever being called. >> >> This might not be an issue as xhci_debugfs_remove_slot() checks >> if (!dev || !dev->debugfs_private) before doing anything, but should >> be checked out. >> > > I checked out the case by adding simple fault injection on xhci_alloc_dev(), > to simulate xhci_debugfs_remove_slot() can be called without > xhci_debugfs_create_slot() being called. > Thanks, patch sent forward -Mathias