From patchwork Tue Jan 12 06:49:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 8013811 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5BB059F88A for ; Tue, 12 Jan 2016 06:51:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8504220114 for ; Tue, 12 Jan 2016 06:51:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 532A720389 for ; Tue, 12 Jan 2016 06:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760545AbcALGvG (ORCPT ); Tue, 12 Jan 2016 01:51:06 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35502 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760710AbcALGt5 (ORCPT ); Tue, 12 Jan 2016 01:49:57 -0500 Received: by mail-wm0-f42.google.com with SMTP id f206so239520825wmf.0 for ; Mon, 11 Jan 2016 22:49:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=IZFSbbl3bi2A8WyY+4WlZOL13OKW8GiAN/CAU10XBIQ=; b=Qaa8OAdwSIhVZa+dU1KaTIEre6VexIckTSLR7alN5W27S/I5K/NW9DuiYmFEqxtFmU mX97YpVJ4w3nm7mq2LnER6vDottk/v/lMTZ8wE7X3imXA2XQAhe1Q4Qv763hg8oePkAq qm1JLbSfW8/xVe4foRVkBdQMZZ1vNWPkui408= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=IZFSbbl3bi2A8WyY+4WlZOL13OKW8GiAN/CAU10XBIQ=; b=X4pd9UINW8V11xR2samlGJ41wHD1J3fF8lKOayauxqbu3bL+NIMNAsZnOzO1AsTsAl 6+f34hr7F1pB66GQup8ndZ4bdCza5/TaedZw5JCExP7QuRve1GJg6BGYtB5QwEt4xmfi YkkuCpSkmlfgVva5hNAimy/XV/n/ocnPc2ON87+M4ZNNTkWoDbxJLky5y3wTG0hbSkGE 27eIh/cjXt6wgycZA82kaJ8Pd4ccDx4PzXhpPW1BZM5xIT6vLkVKlYgQ/f/K+akVZac5 cvVZOueV62Yh/bHHftQpVApUQG+R8RqnXVJWjsHfbit5tyEzJddxxhFaarGEUYrMw3nd Ix3g== X-Gm-Message-State: ALoCoQkFhLaElakr8aXcs4RItjsF5A4O8r0umbA9uELyFpJcYazTPdg15zD6BqThtuoYWSaLgwjsVj8QcL4Lr9HLapzyaH2pWg== X-Received: by 10.28.128.22 with SMTP id b22mr16779223wmd.44.1452581396642; Mon, 11 Jan 2016 22:49:56 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id yz5sm70776886wjc.36.2016.01.11.22.49.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 22:49:55 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: Javier Gonzalez , Javier Gonzalez , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 03/25] lightnvm: add check after mempool allocation Date: Tue, 12 Jan 2016 07:49:17 +0100 Message-Id: <1452581379-18162-4-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452581379-18162-1-git-send-email-m@bjorling.me> References: <1452581379-18162-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier Gonzalez The mempool allocation might fail. Make sure to return error when it does, instead of causing a kernel panic. Signed-off-by: Javier Gonzalez Signed-off-by: Matias Bjørling --- drivers/lightnvm/rrpc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index a1e7488..f4bc986 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -287,6 +287,8 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk) } page = mempool_alloc(rrpc->page_pool, GFP_NOIO); + if (!page) + return -ENOMEM; while ((slot = find_first_zero_bit(rblk->invalid_pages, nr_pgs_per_blk)) < nr_pgs_per_blk) {