Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2835214pxv; Mon, 12 Jul 2021 03:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv3nOHmEUXhX83+VIYt6UFCi0/TwJfLjLriyUI3piYWOlYvkUi+h6yrb/fDsSNj5CugYiT X-Received: by 2002:a17:907:212f:: with SMTP id qo15mr12314226ejb.400.1626084443766; Mon, 12 Jul 2021 03:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084443; cv=none; d=google.com; s=arc-20160816; b=wlEDvr1eYDxr37ojLUeAWyi6Vyi5Bny1AjiXzLrQtlGXa8zcw72l3gkgnXRCyzdRab t7o8YjNlshPEmqcUnptT/DGyzuwxCb16ovplYsDN6CaTclOkeriD48IlANjtYfGOaEQw HUqKPbZ/XSDT9hSHxADbcbYQz3T0gdM0TX/6J/PN+hEZDlT74p67oq2z2NcZBy83AYzE A48HesfRSVniOj8dohgGbd+2erRDelY+8Ch4B3z5MT2kR4yKZLK/O6n0eQ4cRH+puSY3 31JRraiqo0h6NRrDKCZBC9HG1t7lQR7CbBDGl0Lmog3mDouWC3b19wrX9T2TIN+CqWWs 9QTQ== 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=v9ImBsulOL3IKoXCf6xaqRnul/fOS8FSFvaPelHzv1c=; b=V7Gf88LZK2jBfHhs2X5Rcdt/p4taqJAar/EhCHr5B6WTGsfuCHiwqGz0fNv2MQ18u5 1/Y1tpHwS2oXHEVWhBO9O2e++6HX/k5/j8HFzFQMNlGoimcKEByBHJ16zaFwJ3xHgWx2 UffJDEMmblHwiVzuyWIoQ2omp6mKhNI5z4b8Yg9j3ttBepdL+YhT0TPkA7Sao/67bp15 qm9pmNrThIRfzuzrjYICjGOJGCua9pikYrHUg0roz4xZ224OOdsz8iNBw1aJevnoeZ05 Bl/IXjq5v/X9xFiJ7/um7JltXVQfo7wQhOaBTte+hqJ78t6vVEmDue7deE+GL4kenTPI o/VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQF1aqoK; 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 hg16si17092349ejc.410.2021.07.12.03.07.01; Mon, 12 Jul 2021 03:07:23 -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=eQF1aqoK; 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 S1344587AbhGLH3g (ORCPT + 99 others); Mon, 12 Jul 2021 03:29:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240804AbhGLG6y (ORCPT ); Mon, 12 Jul 2021 02:58:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68552613EE; Mon, 12 Jul 2021 06:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072966; bh=q29eO9xaPvOhKMBtvwHVHi2Na9hq7HJD6NGYxtzWhw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQF1aqoKx8/kksAc+BbDsy/H1lVhHPf2tjP5tFHVeLJ1M71JZ4x3c7P6pAhy3vmgI JacpXevnrhpyA/yYFiRosBWzf649siG+YSfpNV8Ry3+cIkJrKWk10/XEuiFVvfFnZ8 9/gveeLmKL+NfKxDOGzlHwSBsSrMLk3EhhrRlFOk= 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.12 028/700] xhci: solve a double free problem while doing s4 Date: Mon, 12 Jul 2021 08:01:51 +0200 Message-Id: <20210712060928.644060730@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 @@ -1924,6 +1924,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;