Received: by 10.192.165.148 with SMTP id m20csp532119imm; Wed, 25 Apr 2018 03:48:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx48pFIuxY6dxJhC2g08Xab2td0RYVIojNJd1iF209zi0jfEMcNBAFZNKY0BrcPGBqJ91dBcL X-Received: by 2002:a17:902:820a:: with SMTP id x10-v6mr28476624pln.203.1524653290231; Wed, 25 Apr 2018 03:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653290; cv=none; d=google.com; s=arc-20160816; b=u3rJs+RNc+HYjevOtOIYFi/y6xFIiB7g5jOORQwX3LGFQQZI6HEZcCEcQxn2A9AuGW NJFogq00yTMo9xSd2nWRZjXUUzfguXdWGI0/1s5474BWUbRnMLb2UYldkttevBdFBatf SiwU1P3338VmO9aAfKISd0sEs/UEukPuhssd8TFtuwrpNGezLUaTbCtNfA5W9azBCUaH pGjA8I47RdhruREgKSlWEQ7z/OKzqcXvjYb/+364/Z0IsSVdAwa9vg4QEj/sSHxhOleq 3SjbKPgZsetueLCoHfaSV7d3w7+T6FoD9CfhzYhhosX5EZaOwfRwFVedVk6malAuvxbQ uCUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uQfCiy4+rpZXeMbuazbeh/dmAHzwDhOkqUvDDqW6a/M=; b=WiBncfI0Zc6j8TsY+yg+Ayid9c1SvU9njzbdIC1vxQeKo6CHNpjcnd2reDGxL/kXZY 0T+k4BVa+CBrFlbwOsv4j8F3WSAdepRAAZVQjhtd2BFF4mZX5OUxBJCllOSb9FSG2WMF XZEr76zWqm4nqYOlndeVxg6Tu2xYWfcxBwFlEL4Xb6Plre9I23SLQfNM+ThkoDiVDj7c vV0kYEEU/c7aNF9OkQEnUxIWRsDpBMdz4yjFi4SRlIFGAG62xRXkrkuOdN0p2JD9uKmG cSoWzZvBJNut3dAKEBnwbZBg4lcNX5DmeIu2kfpu3EclEAulDspy5belZMLKDfObvMtV ZYcQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f2si99326pgs.655.2018.04.25.03.47.55; Wed, 25 Apr 2018 03:48:10 -0700 (PDT) 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; 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 S1754512AbeDYKpK (ORCPT + 99 others); Wed, 25 Apr 2018 06:45:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53502 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754451AbeDYKpH (ORCPT ); Wed, 25 Apr 2018 06:45:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 888C0266; Wed, 25 Apr 2018 10:45:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tang Junhui , Michael Lyle , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 150/183] bcache: return attach error when no cache set exist Date: Wed, 25 Apr 2018 12:36:10 +0200 Message-Id: <20180425103248.568921100@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tang Junhui [ Upstream commit 7f4fc93d4713394ee8f1cd44c238e046e11b4f15 ] I attach a back-end device to a cache set, and the cache set is not registered yet, this back-end device did not attach successfully, and no error returned: [root]# echo 87859280-fec6-4bcc-20df7ca8f86b > /sys/block/sde/bcache/attach [root]# In sysfs_attach(), the return value "v" is initialized to "size" in the beginning, and if no cache set exist in bch_cache_sets, the "v" value would not change any more, and return to sysfs, sysfs regard it as success since the "size" is a positive number. This patch fixes this issue by assigning "v" with "-ENOENT" in the initialization. Signed-off-by: Tang Junhui Reviewed-by: Michael Lyle Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/sysfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -193,7 +193,7 @@ STORE(__cached_dev) { struct cached_dev *dc = container_of(kobj, struct cached_dev, disk.kobj); - ssize_t v = size; + ssize_t v; struct cache_set *c; struct kobj_uevent_env *env; @@ -270,6 +270,7 @@ STORE(__cached_dev) if (bch_parse_uuid(buf, set_uuid) < 16) return -EINVAL; + v = -ENOENT; list_for_each_entry(c, &bch_cache_sets, list) { v = bch_cached_dev_attach(dc, c, set_uuid); if (!v) @@ -277,7 +278,7 @@ STORE(__cached_dev) } pr_err("Can't attach %s: cache set not found", buf); - size = v; + return v; } if (attr == &sysfs_detach && dc->disk.c)