Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6267060imu; Mon, 21 Jan 2019 06:06:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN7LV6JEZ6XNqlgV85zi0P61hT3XMOPCnKz0rNPQBJQ+S/0r0coQi2LGByNnNbPsUEcgauvD X-Received: by 2002:a62:2547:: with SMTP id l68mr29484706pfl.131.1548079605144; Mon, 21 Jan 2019 06:06:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079605; cv=none; d=google.com; s=arc-20160816; b=RoX5gUsarHBBrUA/nmnYawOwazoWM2aOsVdNm5IG3BhIly7tOpSqtvaoK2vLOLCe1k 1ukJfn1A0JcCVSPjh+Vnd3DGeiNld08IbOIWxOclb/C0wFqLQ1siD1Qj4VOhbVcskVlC pLVFFrqquMgjk52eXPMHe8INZZTx+ip8y8iVPLx5EhIqrw1RdwW+/hCSoIO/xWJ9P3fS Revms3dZRvftaOxQ0QtbxCTOifleMNxbb7yzbL2gmXhdKmkE5F2pz5gZ1TazUHuJjIrY alYa7+7DxuF+5oxTly+78BytmxiSn+G+X1aVm7LnCBb2Sg0naMuNbhXS6YQ/HU+TRFnz JOvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UPTaCvRwITfhLH/QaT9NN4fFlzkAfCYVkD2cyaoHMOk=; b=JoylYh8LEVKfT2oNr57HZ+e964LF/XO3daxKpS+2ewrM9vWZmYDPefx13K8ZWGLNjq +7J5aBjNSVRPYdv5AAQnFy+acLEoS5HUfno4lImQ3YcqffjkTBSJ6Qs+rYUu2nBD+53F Sd91v/wCXWDe4ocgl7iGlsbZOpbKThxEUX0tEKW+nRTWvXAaDLWpFD36cq7ohB5gF9uu zEBdviveloIVVaxegaTo21rcUb8mfOBu+mSlSw+gqt6MFpwe5qlPA9kOchyCgjp81FX4 0EkspGyVBmUkTcYgviToEuv9b+H0VK4Vs94kCmij5xtfwhZ35mY6OkZYzgfgQcOYpID9 lCRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NkHKtz4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j186si12592932pfb.174.2019.01.21.06.06.29; Mon, 21 Jan 2019 06:06:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NkHKtz4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728984AbfAUOCT (ORCPT + 99 others); Mon, 21 Jan 2019 09:02:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:49766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732756AbfAUOCS (ORCPT ); Mon, 21 Jan 2019 09:02:18 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1BF421734; Mon, 21 Jan 2019 14:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079337; bh=xt3K6zjpq4/ogTZKuj//FzF3ipctRcEuVB52vyq9/tE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NkHKtz4u4KygLgJzE/jFZPJl821QZAKpPspZZuxWE21fnIfJT4K93bQWz+1m/2jEJ ChFN06rSgrTOi1ju1Sev/YKefeJ6kK2bFhE6coojtbZ0uUg067jUw5m0rEgYMpqRIH lFK/L4rfAfAHN6ZgYKm+e1C5qP93Ym39ija/bcpQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Jens Axboe Subject: [PATCH 4.19 90/99] loop: Push loop_ctl_mutex down to loop_change_fd() Date: Mon, 21 Jan 2019 14:49:22 +0100 Message-Id: <20190121134917.933331750@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit c371077000f4138ee3c15fbed50101ff24bdc91d upstream. Push loop_ctl_mutex down to loop_change_fd(). We will need this to be able to call loop_reread_partitions() without loop_ctl_mutex. Signed-off-by: Jan Kara Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/loop.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -692,19 +692,22 @@ static int loop_change_fd(struct loop_de struct file *file, *old_file; int error; + error = mutex_lock_killable_nested(&loop_ctl_mutex, 1); + if (error) + return error; error = -ENXIO; if (lo->lo_state != Lo_bound) - goto out; + goto out_unlock; /* the loop device has to be read-only */ error = -EINVAL; if (!(lo->lo_flags & LO_FLAGS_READ_ONLY)) - goto out; + goto out_unlock; error = -EBADF; file = fget(arg); if (!file) - goto out; + goto out_unlock; error = loop_validate_file(file, bdev); if (error) @@ -731,11 +734,13 @@ static int loop_change_fd(struct loop_de fput(old_file); if (lo->lo_flags & LO_FLAGS_PARTSCAN) loop_reread_partitions(lo, bdev); + mutex_unlock(&loop_ctl_mutex); return 0; - out_putf: +out_putf: fput(file); - out: +out_unlock: + mutex_unlock(&loop_ctl_mutex); return error; } @@ -1470,12 +1475,7 @@ static int lo_ioctl(struct block_device case LOOP_SET_FD: return loop_set_fd(lo, mode, bdev, arg); case LOOP_CHANGE_FD: - err = mutex_lock_killable_nested(&loop_ctl_mutex, 1); - if (err) - return err; - err = loop_change_fd(lo, bdev, arg); - mutex_unlock(&loop_ctl_mutex); - break; + return loop_change_fd(lo, bdev, arg); case LOOP_CLR_FD: return loop_clr_fd(lo); case LOOP_SET_STATUS: