From patchwork Sat Oct 22 07:18:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087608wrr; Sat, 22 Oct 2022 00:37:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM704eimPcHe+Ml5ypQxtY78HqM+IRMpG77UnH/6WdweSGOiAFDE20dKGrwsq2s6WK33pQHN X-Received: by 2002:a17:907:6d27:b0:78d:46f6:c59e with SMTP id sa39-20020a1709076d2700b0078d46f6c59emr18918618ejc.30.1666424226204; Sat, 22 Oct 2022 00:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424226; cv=none; d=google.com; s=arc-20160816; b=kkOuuOMHVE2KL41IhAf6I++dU/8nWS4X3OlL2n8WsqU3FhAnBmNYZfbR02yLKNJ6na kvtGiJQO7pWB9H38SSC9Rg0iZy6MvZ5nXb+XTRe22Hz3BQXgg98+E1MuYHDTaT1S6jpB tF7WohAwT/nDf/QtyrFPbv7SdeAc8i3TrOnjVYYw9h1o3t34hKo0MjOzD1ikN8o/AOiM zVMQhTCg95Y3vL1uS6CR35dVH0A7ETFhUGhB30Osgy39sx0ii3wUyELtowqN7gNq3W0A abyZY8qr+gsu+apGl998WfnO5/NDkbdAmobyMKbx2VQJRns+FVAGt5d6TT1XdsB/R6zZ Czqw== 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=+CvRpaSl0iUjdb4ggzzMlvLFPMYMUJaHhIUNJI4GGsk=; b=iMFp9QSyX6s33q3+zaZ7Z3ZxVOV8LBBO7sgKbKWrcGrf3pYBCA0G+Jgs0LXtR49Ouk Xm5UJAXrr0ZdW3QB5sfU3hZJ84RyoLZESVDxHYyaxEr/4BAJThjttbXoylfb06m94cs8 M8mLtyd077cIzBl4Gdm7fNcUk6nRRlw3kBu46LP1o2IxN9zZNhKmlXvkWnHnzf+90oeB zZBsx1El/iVcfIWGXIGfZfgk1dT/tR5SBiJUQ+BsjWeZrSm9KM57vFds5hna+liahR5d m6tsseHMKNJdZPT9Z7jKLN78dtdefK21/vlFY1o9lChC3GcF/wecxDZ2Oim5Uz8PGgK6 8C7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TMvJz0Mf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020aa7c301000000b004612915d1a0si4493933edq.507.2022.10.22.00.36.42; Sat, 22 Oct 2022 00:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TMvJz0Mf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230220AbiJVHfw (ORCPT + 99 others); Sat, 22 Oct 2022 03:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiJVHfR (ORCPT ); Sat, 22 Oct 2022 03:35:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE4E4E60B; Sat, 22 Oct 2022 00:34:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8B0BE60ADA; Sat, 22 Oct 2022 07:34:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 787D5C433D6; Sat, 22 Oct 2022 07:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424090; bh=fgdXg1wobOdeihxoqquNWvbEhAq2SyCVppXeIRBGkRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMvJz0MfUM4sCCdr1HUwErv5EsYadjEQutN6wdEYF7nWE9aZNdgpMmxjAk0gfTQ6K jqnTIsLWE2gwG5i95kdlHWxHOGz0E5x7mToI3U4TUWga4Gm+bQReRveaqXI++4sHQI FJXoIjTLL+YCiA5HueRjdkOZOkNalU1ZSfxVZZZo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rafael Mendonca , Mathias Nyman Subject: [PATCH 5.19 024/717] xhci: dbc: Fix memory leak in xhci_alloc_dbc() Date: Sat, 22 Oct 2022 09:18:23 +0200 Message-Id: <20221022072419.380936693@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372449027483231?= X-GMAIL-MSGID: =?utf-8?q?1747372449027483231?= From: Rafael Mendonca commit d591b32e519603524a35b172156db71df9116902 upstream. If DbC is already in use, then the allocated memory for the xhci_dbc struct doesn't get freed before returning NULL, which leads to a memleak. Fixes: 534675942e90 ("xhci: dbc: refactor xhci_dbc_init()") Cc: stable@vger.kernel.org Signed-off-by: Rafael Mendonca Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220921123450.671459-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -988,7 +988,7 @@ xhci_alloc_dbc(struct device *dev, void dbc->driver = driver; if (readl(&dbc->regs->control) & DBC_CTRL_DBC_ENABLE) - return NULL; + goto err; INIT_DELAYED_WORK(&dbc->event_work, xhci_dbc_handle_events); spin_lock_init(&dbc->lock);