Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2717727pxv; Sun, 11 Jul 2021 23:41:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7xAONb+U0PQLXHzSdd/I1KGLWnKG1iVE3TvX0gai7lgDdv+8p0h/40UU/6ObRWZsy3MLG X-Received: by 2002:a17:906:72d9:: with SMTP id m25mr31406238ejl.58.1626072077691; Sun, 11 Jul 2021 23:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626072077; cv=none; d=google.com; s=arc-20160816; b=gmiDhxqONozZnQ+SUfpLm0SRe7X2q+YZAphAPw1DpDGvLNolTkLktdpeEnwbUyxpqi cADsCcGaRqo0vAfo4crmK2mXWYy8BcBwwEn4lV/XvJsWKCIwbsHRwPxb/AP9SF9vZqGb 0lRpZVsLHT5BZK3ifeTGFyI/N+CBl8er0mrf1fZ/SopXdiiz5krZQZOHyif+pSXFhIKn osoVn0NBcRxnPFvNCXjHkY76apIrrA+TGckc2f/6l/LZ9wLOjw7AixnN3GfZCvKzSxl2 zZNfAmD+UeJKAUV213ShEdq4zpodE80FwFgi05pqhrcc9Th2EiXTv6ROvc126tVlE6uN f57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eFjfnb1krtUy4qTOe6HTsdQK9/LEvwu7ZL9pOPMo3ss=; b=YMtCu6j53+pqenqGwXh/g929cPuaZpMZqf1M7xrbc07N4600uDxN+hq/tTvsaMPZgW hp4GYSa6cnYk7J5BxXfns6WYb2oXDe1IeoUJxNRfQw/RLrS19/NVWDP2+YtikrY2gDnm U6fcDjvT5YvRTDDajhEUrA1uZ2wP8oudMCisKGunbk2i9Mq3qwR5YSnJnDQgWKlTGSlu k17MFk/LayMabZZ24lDzcagIHjEoBrY5dOBH5TJ9jrKgVM/trWDub7FNSIkCTQU0E8Bs ZLMf0PPtWSPFmcabknFIZlxj0dG7BE99d3G4QwpVLf7LT1BSrb1BydEDr6OhZ3eP9uqR FgJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mq7meqjx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j11si16465781ejj.109.2021.07.11.23.40.55; Sun, 11 Jul 2021 23:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mq7meqjx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238641AbhGLGle (ORCPT + 99 others); Mon, 12 Jul 2021 02:41:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:55532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237109AbhGLGeJ (ORCPT ); Mon, 12 Jul 2021 02:34:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 56A8961158; Mon, 12 Jul 2021 06:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071424; bh=V+1jT8dQ4yqVyUYSiGrM5IoWp0DqNd8wD2MMeZNawdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mq7meqjxd8EIf2G7ZlvPwgESp0zOk2x6SUrK110kMtx2Q6ci+7nBOiPcvbAfM0qP6 2PK+JRZ0OVNruY4FFL/HkhB8RPg6Vthqwo8QTnUR5/5OEWbJzhxqo+Z5bEnS4doDBD dT3kFXSzfAKq7f2cQqPfR2aAKukE6ycuGzV+t2Sg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiantao Zhang , Tao Xue , Mathias Nyman Subject: [PATCH 5.10 026/593] xhci: solve a double free problem while doing s4 Date: Mon, 12 Jul 2021 08:03:06 +0200 Message-Id: <20210712060846.062008987@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhangjiantao (Kirin, nanjing) commit b31d9d6d7abbf6483b871b6370bc31c930d53f54 upstream. when system is doing s4, the process of xhci_resume may be as below: 1、xhci_mem_cleanup 2、xhci_init->xhci_mem_init->xhci_mem_cleanup(when memory is not enough). xhci_mem_cleanup will be executed twice when system is out of memory. xhci->port_caps is freed in xhci_mem_cleanup,but it isn't set to NULL. It will be freed twice when xhci_mem_cleanup is called the second time. We got following bug when system resumes from s4: kernel BUG at mm/slub.c:309! Internal error: Oops - BUG: 0 [#1] PREEMPT SMP CPU: 0 PID: 5929 Tainted: G S W 5.4.96-arm64-desktop #1 pc : __slab_free+0x5c/0x424 lr : kfree+0x30c/0x32c Call trace: __slab_free+0x5c/0x424 kfree+0x30c/0x32c xhci_mem_cleanup+0x394/0x3cc xhci_mem_init+0x9ac/0x1070 xhci_init+0x8c/0x1d0 xhci_resume+0x1cc/0x5fc xhci_plat_resume+0x64/0x70 platform_pm_thaw+0x28/0x60 dpm_run_callback+0x54/0x24c device_resume+0xd0/0x200 async_resume+0x24/0x60 async_run_entry_fn+0x44/0x110 process_one_work+0x1f0/0x490 worker_thread+0x5c/0x450 kthread+0x158/0x160 ret_from_fork+0x10/0x24 Original patch that caused this issue was backported to 4.4 stable, so this should be backported to 4.4 stabe as well. Fixes: cf0ee7c60c89 ("xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2") Cc: stable@vger.kernel.org # v4.4+ Signed-off-by: Jiantao Zhang Signed-off-by: Tao Xue Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20210617150354.1512157-5-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-mem.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1938,6 +1938,7 @@ no_bw: xhci->hw_ports = NULL; xhci->rh_bw = NULL; xhci->ext_caps = NULL; + xhci->port_caps = NULL; xhci->page_size = 0; xhci->page_shift = 0;