From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932485AbbFWAlf (ORCPT ); Mon, 22 Jun 2015 20:41:35 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33040 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754027AbbFWAlI (ORCPT ); Mon, 22 Jun 2015 20:41:08 -0400 Message-ID: <1435020062.6479.0.camel@ingics.com> Subject: [PATCH] block: partition-generic: Catch alloc_part_info failure From: Axel Lin To: Jens Axboe Cc: Ming Lei , Yasuaki Ishimatsu , linux-kernel@vger.kernel.org Date: Tue, 23 Jun 2015 08:41:02 +0800 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make add_partition() return proper ERR_PTR if alloc_part_info() fails. This ensures the caller of add_partition() can catch the error by IS_ERROR macro. Signed-off-by: Axel Lin --- block/partition-generic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 0d9e5f9..94de205 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -309,8 +309,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, if (info) { struct partition_meta_info *pinfo = alloc_part_info(disk); - if (!pinfo) + if (!pinfo) { + err = -ENOMEM; goto out_free_stats; + } memcpy(pinfo, info, sizeof(*info)); p->info = pinfo; } -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/