Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2762497imj; Mon, 11 Feb 2019 08:06:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ36m0c0hqMNPK5UCeq0JF6kPI1R7Q8mk2VSkDcyXclhdQWqlvIbN0MDjWMUCpewZhPpDdh X-Received: by 2002:a62:6f49:: with SMTP id k70mr37094313pfc.7.1549901196941; Mon, 11 Feb 2019 08:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901196; cv=none; d=google.com; s=arc-20160816; b=PpCTGLz++Aes9XdTni74OUtpHR5vOobtfCAjSWa/UX04S/0h3APpeeTp8SkWw3xKXm 3yterYL0H88I8ziMd1Plra1qEgwvUwNsjwk/lqqJ8sbshFeb4JiRZgY1aFaxKYMU87M2 x67L1xmSpliN1xrmrv7PV3Lby0ER0t3rBIxZWfFuj/vpI8aMnUMXHrg1Hs4+aO8ERzo5 V+zxOHRlMiaCTfKHputWrkosVj8DtsEYzRKIr4FQXHtffTa4brEQWGQV6uOg/XiEjfNe hjCnmTeGVUyl3HApM6A+HkqpWHKT+moOfrskUbTc+Iov0SEzkd6ENhVnMbI3OuHcw5JU GdRA== 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=0Dr1iRir/DZ6+QIwXut9i/v6BVwt2XmIElWCD2SNRJo=; b=OY7TmPd5+6iy/mUEksXM5O6muSEVIYD8hyo6DjTHDZ44cYfSZ0YjV90q3NfwDYcCEF VUb83USc4Vf24WfZ7wp1trzGcdwHkKnAglrnQuKU+1abUGvKMmyFrNOebaGRn/BaRb4E pFrV6TixH/pokjyVOURRH7PcIfvGJheMjpRzKZHSoZno+nDV8EVaA9Fl+BXZ+7AYzuif ZJbaDgW8G6nHyr0WvbmoAI3Hqb19UFEZCtmQzvT+WyWBekfq8ceX8seMnqaF/7h12hwF KDLCD1W82QCfrRWh1EY65gl7XCfhF/DoJ/NWhHbfdkwPGH5QZwZLNITr5mPXA338NCN8 Lb1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lWODCCKW; 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 a5si9865895pgg.120.2019.02.11.08.06.05; Mon, 11 Feb 2019 08:06:36 -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=lWODCCKW; 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 S1730167AbfBKQFG (ORCPT + 99 others); Mon, 11 Feb 2019 11:05:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:33926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728881AbfBKO2B (ORCPT ); Mon, 11 Feb 2019 09:28:01 -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 A4A0820838; Mon, 11 Feb 2019 14:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895281; bh=sQTRKy3+4q+5ueS/b4/wzN3bw+raermDVbyqjvqam5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWODCCKW0haH1Taa1iZqXfgX1Bu4SPGaZ1G/T4VkpsbOgiWN6ZyYlBG8zq+MwY+Zz EwsnYeOpe8b/GxfSXq6KBXaTmiPEN8Ck6yP0rj5dZCxMkLAwVtjg28QwzwF1vAbb0W 650WC6TJ26GtCxv8c+a05V0j/GeTwDQ2TBp15Q7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hua Su , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , Jens Axboe , Sasha Levin Subject: [PATCH 4.20 154/352] lightnvm: pblk: add lock protection to list operations Date: Mon, 11 Feb 2019 15:16:21 +0100 Message-Id: <20190211141856.526780630@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit fde201a466c6ad5efd72cb54fdf2cefa8b6c6ad7 ] Protect the list_add on the pblk_line_init_bb() error path in case this code is used for some other purpose in the future. Signed-off-by: Hua Su Reviewed-by: Javier González Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/lightnvm/pblk-core.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 6944aac43b01..247112e1db94 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1295,15 +1295,22 @@ int pblk_line_recov_alloc(struct pblk *pblk, struct pblk_line *line) ret = pblk_line_alloc_bitmaps(pblk, line); if (ret) - return ret; + goto fail; if (!pblk_line_init_bb(pblk, line, 0)) { - list_add(&line->list, &l_mg->free_list); - return -EINTR; + ret = -EINTR; + goto fail; } pblk_rl_free_lines_dec(&pblk->rl, line, true); return 0; + +fail: + spin_lock(&l_mg->free_lock); + list_add(&line->list, &l_mg->free_list); + spin_unlock(&l_mg->free_lock); + + return ret; } void pblk_line_recov_close(struct pblk *pblk, struct pblk_line *line) -- 2.19.1