Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759127AbcCVKrc (ORCPT ); Tue, 22 Mar 2016 06:47:32 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57036 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758844AbcCVKnR (ORCPT ); Tue, 22 Mar 2016 06:43:17 -0400 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Jianjian Huo , Kamal Mostafa , Luis Henriques Subject: [PATCH 3.16.y-ckt 133/142] bcache: add mutex lock for bch_is_open Date: Tue, 22 Mar 2016 10:41:02 +0000 Message-Id: <1458643271-4227-134-git-send-email-luis.henriques@canonical.com> In-Reply-To: <1458643271-4227-1-git-send-email-luis.henriques@canonical.com> References: <1458643271-4227-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.16 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1256 Lines: 36 3.16.7-ckt26 -stable review patch. If anyone has any objections, please let me know. ---8<------------------------------------------------------------ From: Jianjian Huo commit 789d21dbd9d8889e62c79ec19585fcc97e42ef07 upstream. Since bch_is_open will iterate linked list bch_cache_sets and uncached_devices, it needs bch_register_lock. Signed-off-by: Jianjian Huo Cc: Kamal Mostafa [ luis: backported to 3.16: adjusted context ] Signed-off-by: Luis Henriques --- drivers/md/bcache/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 72e660cafadd..70db24e41947 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1950,10 +1950,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr, if (IS_ERR(bdev)) { if (bdev == ERR_PTR(-EBUSY)) { bdev = lookup_bdev(strim(path)); + mutex_lock(&bch_register_lock); if (!IS_ERR(bdev) && bch_is_open(bdev)) err = "device already registered"; else err = "device busy"; + mutex_unlock(&bch_register_lock); if (attr == &ksysfs_register_quiet) goto out; }