Return-Path: Received: from mail-bl2nam02on0101.outbound.protection.outlook.com ([104.47.38.101]:39744 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965111AbeCSP7Z (ORCPT ); Mon, 19 Mar 2018 11:59:25 -0400 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Peter Rosin , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 051/281] i2c: mux: reg: put away the parent i2c adapter on probe failure Date: Mon, 19 Mar 2018 15:58:50 +0000 Message-ID: <20180319155742.13731-51-alexander.levin@microsoft.com> References: <20180319155742.13731-1-alexander.levin@microsoft.com> In-Reply-To: <20180319155742.13731-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Peter Rosin [ Upstream commit 68118e0e73aa3a6291c8b9eb1ee708e05f110cea ] It is only prudent to let go of resources that are not used. Fixes: b3fdd32799d8 ("i2c: mux: Add register-based mux i2c-mux-reg") Signed-off-by: Peter Rosin Signed-off-by: Sasha Levin --- drivers/i2c/muxes/i2c-mux-reg.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-re= g.c index c6a90b4a9c62..91b10afc8c34 100644 --- a/drivers/i2c/muxes/i2c-mux-reg.c +++ b/drivers/i2c/muxes/i2c-mux-reg.c @@ -196,20 +196,25 @@ static int i2c_mux_reg_probe(struct platform_device *= pdev) res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); mux->data.reg_size =3D resource_size(res); mux->data.reg =3D devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(mux->data.reg)) - return PTR_ERR(mux->data.reg); + if (IS_ERR(mux->data.reg)) { + ret =3D PTR_ERR(mux->data.reg); + goto err_put_parent; + } } =20 if (mux->data.reg_size !=3D 4 && mux->data.reg_size !=3D 2 && mux->data.reg_size !=3D 1) { dev_err(&pdev->dev, "Invalid register size\n"); - return -EINVAL; + ret =3D -EINVAL; + goto err_put_parent; } =20 muxc =3D i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 0, 0, i2c_mux_reg_select, NULL); - if (!muxc) - return -ENOMEM; + if (!muxc) { + ret =3D -ENOMEM; + goto err_put_parent; + } muxc->priv =3D mux; =20 platform_set_drvdata(pdev, muxc); @@ -235,6 +240,8 @@ static int i2c_mux_reg_probe(struct platform_device *pd= ev) =20 add_adapter_failed: i2c_mux_del_adapters(muxc); +err_put_parent: + i2c_put_adapter(parent); =20 return ret; } --=20 2.14.1