Return-Path: From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Dan Carpenter , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 212/281] cxl: Unlock on error in probe Date: Mon, 19 Mar 2018 16:02:04 +0000 Message-ID: <20180319155742.13731-212-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: linux-kernel-owner@vger.kernel.org List-ID: From: Dan Carpenter [ Upstream commit 58d876fa7181f2f393190c1d32c056b5a9d34aa2 ] We should unlock if get_cxl_adapter() fails. Fixes: 594ff7d067ca ("cxl: Support to flash a new image on the adapter from= a guest") Signed-off-by: Dan Carpenter Acked-by: Frederic Barrat Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- drivers/misc/cxl/flash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c index c63d61e17d56..381a9a166f93 100644 --- a/drivers/misc/cxl/flash.c +++ b/drivers/misc/cxl/flash.c @@ -401,8 +401,10 @@ static int device_open(struct inode *inode, struct fil= e *file) if (down_interruptible(&sem) !=3D 0) return -EPERM; =20 - if (!(adapter =3D get_cxl_adapter(adapter_num))) - return -ENODEV; + if (!(adapter =3D get_cxl_adapter(adapter_num))) { + rc =3D -ENODEV; + goto err_unlock; + } =20 file->private_data =3D adapter; continue_token =3D 0; @@ -446,6 +448,8 @@ static int device_open(struct inode *inode, struct file= *file) free_page((unsigned long) le); err: put_device(&adapter->dev); +err_unlock: + up(&sem); =20 return rc; } --=20 2.14.1