Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9172419pxu; Mon, 28 Dec 2020 08:22:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC7QT3mVwTN2dvmek2fzzmJa9JOmy9aamwpZ/rzG9konZ7tMvAbOuvfRLuYXlMxjJYGCvO X-Received: by 2002:a50:fb85:: with SMTP id e5mr42372476edq.153.1609172540076; Mon, 28 Dec 2020 08:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609172540; cv=none; d=google.com; s=arc-20160816; b=K8xkUPoo+ALPnDc3dSWjw4KKc0yhCkUrAJcPf1lN0Mv8orcMzRCecB4TOiTkn3gQuf JEhhiIFYDCwQO58PAf5hPdGkPGWYgHAzcjcIQzWOMUeFuXekhnXaWttCxt2zg5yzl1QW QBrMUF6fSAgCc0k6YnKGyNOJ1LEvmZcXurtZhHbSfFvKIn6HVheqfF4O3Y6ixhijmtCx YPrKqfi2+oorL0dwlj9ivP0EE6MugdhiXo69fSERosJGEHUXVT0GCVpMoHQopRMPuq9M gmWuMUEGBrRKZiRKEhXo98CShIPNXDXBkOp00FnEtYXDfgvuNGeNHlCqI2Ds59gGhn8C lOIA== 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=w4JEbEqC92HhTL3dZfzuwiyIeFcdIHPKRmmbXUxUTTw=; b=jTFQHNuRQe0VlVR8jLsqbTLSO1Pb6s5OzjYpR9umdLV/HdseN7R0YBO6OpZ7le6GKz eME1rSDpFZjBemy9Ke8Hm/xVbvUps1tqvnJb2/2TiGbA+lHVmBySsfIFGY3Phvl2xaFT qDfssDD2Xi/5M4wnr4++F9n+mus9XwXqgqbOOIIhe5writF+b/k9Ri3FCCPGG95/kxJA 0y7GqarvV8b0x2VHtgBStg4nTgW7tim25qMwi6AV3pzFIchXbRm3LDowAcqUlQf5+EQB xFkXuijAXggS2HTele2p1p7nDYbuRrV1gB+ncqtSIX/tY+4sKxj1fOjfzwGlEkN7Ix5o QVGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lc60eVXI; 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 s17si18662974eju.360.2020.12.28.08.21.56; Mon, 28 Dec 2020 08:22:20 -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=Lc60eVXI; 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 S1732526AbgL1QTm (ORCPT + 99 others); Mon, 28 Dec 2020 11:19:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:42214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732477AbgL1NOT (ORCPT ); Mon, 28 Dec 2020 08:14:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DD9D206ED; Mon, 28 Dec 2020 13:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161244; bh=y6ZQLzeaVOvYgTngfNR5QHOnwq4Foe2LejqIuPXYogY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lc60eVXIAnH5M4niD8p/a+G/Mg7oKpRWlF9E6bt5HZs9ahyrLwBPXHNRD7Ot9NqSu BQV0n5XXEya8ISv1Kf1eU/0Mgjo1X1Dq/wkl4eulAzlmGVv0A8XceNRR6CCGLWv+7H 6K8zNd6ysKp5RKvuxDEjz/gWNjD9oYifkU8OPWlg= 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 4.14 151/242] usb: oxu210hp-hcd: Fix memory leak in oxu_create Date: Mon, 28 Dec 2020 13:49:16 +0100 Message-Id: <20201228124912.140077998@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 ed20fb34c897f..1d3a79c2eba2f 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -3732,8 +3732,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