Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9112636pxu; Mon, 28 Dec 2020 06:59:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJw83IxgN6Xa+zkGj0GgU0DoT1b5GYLukgHF6fOpYyjZu62JDfGA3X+fcmuzaaFEmKI25zOB X-Received: by 2002:a17:906:68d1:: with SMTP id y17mr42194541ejr.447.1609167562669; Mon, 28 Dec 2020 06:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167562; cv=none; d=google.com; s=arc-20160816; b=Jjl07WAZk78H224mpKZsUvKgR0h9pZnWoyaYrvdntXJqF+mhmL2k0PA5b6TGD8MQMa cNT1KykRzlwE72m8H9S5P4f5DWYcy4Q3K4DLtsQf2eaKfMLhVBW6bBzmJWfVekWlCkJ5 FhNb0RjM+Q+XNNDqQQMm1BkKRWezFNuy7SCEIpbWZFLARRjiMxgacYxiEX6ZDMpaPgt5 IWmu/NBGibZFeWe8V2xPlpLZ0WVXmRYGvU+vjNtSN15opr3oYoPERfP51ipEO7l2ziIs RxttSwSCVLzfsFS8hA3I/v5HjWtLPNt909AyjH6ondxRbaGimCkRDY0OT8pDDXgGhlN1 d3Hw== 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=JUrwXPn4tKqVJADIpJ/IspR4PMfrK5MQa7w7ljODVok=; b=LV9LdR5CmDEUeW23378H002fhZLP8axP+guthUC9ATJNiu/zwnXwv8hEqTz48+NAwW met9atbaXvdGfVwduutcdnx9H0ZhfyEzYE9aJS4wjWOKydnQXZcJqhlKSu0xPwElvp4V vnMJ0ELOpX8Pv66NGb2DIV/ikNMAyNC10JtLbzA+6tE0cArS9+RGrH3bqkpUmco+liC/ e+zhtYIZXqSBbugTbtcqo11L2nGGxMoe0aWGDrTMfC2zCZ6F8xeyRk9FhDloX8+UCB3y X+CbFFRxFx5BH98hONvJp9m9+hQQ9CSBJGgMDmKiED78rdfnNP1ZkQSSsG60NWmUZ5lo DXSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wq3E9ymF; 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 e21si15374192edj.402.2020.12.28.06.58.54; Mon, 28 Dec 2020 06:59:22 -0800 (PST) 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=Wq3E9ymF; 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 S2502324AbgL1O4Z (ORCPT + 99 others); Mon, 28 Dec 2020 09:56:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:51720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2441283AbgL1OQz (ORCPT ); Mon, 28 Dec 2020 09:16:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AA56E206D4; Mon, 28 Dec 2020 14:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165000; bh=jDSPTEhSlxTkOcOnMAMQu7TXmiAvvs+/mjmX0Io/OYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wq3E9ymFmI94s0H5zyPOZ2lXlEUXAXTqU7HInK+be9MfToL9urR/VaRWFA2Pw/yuJ o7/g2GSloqi2fkYI0uiqOTBWpKDa1HNQYLxraLqq/7VMKpKdGw6JOo+nBFKnyeE+dV W3FDWeklqrY+AU9IxNGgFm5O87R81M9ytVU3yfs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhang Qilong , Sasha Levin Subject: [PATCH 5.10 373/717] usb: oxu210hp-hcd: Fix memory leak in oxu_create Date: Mon, 28 Dec 2020 13:46:11 +0100 Message-Id: <20201228125038.879134582@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Zhang Qilong [ Upstream commit e5548b05631ec3e6bfdaef1cad28c799545b791b ] usb_create_hcd will alloc memory for hcd, and we should call usb_put_hcd to free it when adding fails to prevent memory leak. Fixes: b92a78e582b1a ("usb host: Oxford OXU210HP HCD driver") Reported-by: Hulk Robot Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201123145809.1456541-1-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/oxu210hp-hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index 27dbbe1b28b12..e832909a924fa 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -4151,8 +4151,10 @@ static struct usb_hcd *oxu_create(struct platform_device *pdev, oxu->is_otg = otg; ret = usb_add_hcd(hcd, irq, IRQF_SHARED); - if (ret < 0) + if (ret < 0) { + usb_put_hcd(hcd); return ERR_PTR(ret); + } device_wakeup_enable(hcd->self.controller); return hcd; -- 2.27.0