Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3702523imu; Mon, 28 Jan 2019 09:17:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN647qBogzRpksHq9MI215k683ns6RnHNxFRJL/EfzY7aTp0x/NoFEfPdWqyJdro4gzkXSnH X-Received: by 2002:a17:902:8d8e:: with SMTP id v14mr22355606plo.133.1548695868609; Mon, 28 Jan 2019 09:17:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695868; cv=none; d=google.com; s=arc-20160816; b=ih+OJ8Ij89eJ2xBHrbwqnjvfrykk3katXihMyTBoR60cZGnJZo0lMRL9851zOACeoT 25f9jA1mRf88QRH8va+tjeKOszP2y6DdyDfo8Dryq3n0C0yvUAeLlOHOyOeU1pNDpnTz Z2Mf1kFtgMOCZMfkmGfHjGjTYr6aL7MO8CLM01T/ccIvGCTc6+mPzXGO7H4wr3QOvR1e VTvWX6IrMVesmumlLZp8LPGZUd8Op5MmOSvPw0WHqJe0CbckVez26s57hYIgP5zRRu+k R/CiFQufsPTWJEXl4UiHe27fsRTo4x6rhHo4xUtclDqeV1viWlpSA9YGkmYTkjaG8Hru 6WIw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RdQl3nVZJ3epK+Sd9saWJrNHEgGDrZQM3ROJBBccBx0=; b=uFxbv38Pc55OvhI4gjwHoQDtM8+P2ohIp6+9WPgkmn0tCa89lECh9qkkgMB+4pnpbf ZlgkffO8gX1QexbVv/nNZVOzs4aiOP0fA9MygGehMSh3jsdnOSlhxp2xSfp5awyod01w AMPM6rbza86wvnTdrHt+tqA9m5YH95SvmuOGNF+0OuEUB6AGAhDwZTNdky7oy6sRmEmh +JtQv66C25PtuAAj5sZqzIZKMhZzQPYqjs12+h2NBH9qlc2vmX0vjvPHEmQN0H/JBb4h S31Au/U6I/MesnpJSeVuKzSeukQvgDptDIABnMLNAMDbdcoPkrlaXuqCzxYkc7enaRLx 0Hrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kQxeDmHx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si32525889pfb.41.2019.01.28.09.17.33; Mon, 28 Jan 2019 09:17:48 -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=kQxeDmHx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732113AbfA1RRL (ORCPT + 99 others); Mon, 28 Jan 2019 12:17:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:53742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731102AbfA1QF5 (ORCPT ); Mon, 28 Jan 2019 11:05:57 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6D2AA20989; Mon, 28 Jan 2019 16:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691557; bh=upkpr6tiik9t0OdDw1gRFJ+UloH0HXmyA2bU0mNJEvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQxeDmHx7BEzuPBHdGGQsyYiQ7Ft60OtWGbijHvSMJpfq2SAn0SSs2JOLATm6cLKo BmNFH3wata1f3S/o18nZrvMJJwv6Xs2xb3oyrn7f6Hdu9zi8/QXB5WOWHN8e5sRSTF VKiwEP1rf+vU7aHKzA19MyNRnVufyzig2GgqFsfg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hua Su , =?UTF-8?q?Matias=20Bj=C3=B8rling?= , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 140/258] lightnvm: pblk: add lock protection to list operations Date: Mon, 28 Jan 2019 10:57:26 -0500 Message-Id: <20190128155924.51521-140-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hua Su [ 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 2940cdc87af1..95be6e36c7dd 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1252,15 +1252,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