From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753377AbbBDBHW (ORCPT ); Tue, 3 Feb 2015 20:07:22 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:64031 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750721AbbBDBHV (ORCPT ); Tue, 3 Feb 2015 20:07:21 -0500 Date: Wed, 4 Feb 2015 10:07:20 +0900 From: Sergey Senozhatsky To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, jmarchan@redhat.com, minchan@kernel.org, ngupta@vflare.org, opensource.ganesh@gmail.com, sergey.senozhatsky@gmail.com, mm-commits@vger.kernel.org Subject: Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree Message-ID: <20150204010720.GC527@swordfish> References: <54d155bf.k9GCVwDVqT17beYC%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54d155bf.k9GCVwDVqT17beYC%akpm@linux-foundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (02/03/15 15:11), akpm@linux-foundation.org wrote: > tweak comment > Thank you, sir. Andrew, can you please squash the following patch? --- >>From 22f0be96df55513a3d764ea880d5b3e99669f8f7 Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Wed, 4 Feb 2015 09:59:06 +0900 Subject: [PATCH] zram: set default dev_id value to zero in zram_init() Set dev_id to zero and fix zram_devices allocation error handling path, can pass uninit dev_id to destroy_devices(). cosmetic: change destroy_devices() message from pr_debug() to pr_info(), as proposed by Minchan Kim. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 79c5da9..0bb4fa0 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1138,12 +1138,12 @@ static void destroy_devices(unsigned int nr) kfree(zram_devices); unregister_blkdev(zram_major, "zram"); - pr_debug("Destroyed %u device(s)\n", nr); + pr_info("Destroyed %u device(s)\n", nr); } static int __init zram_init(void) { - int ret, dev_id; + int ret = -ENOMEM, dev_id = 0; if (num_devices > max_num_devices) { pr_warn("Invalid value for num_devices: %u\n", @@ -1159,10 +1159,8 @@ static int __init zram_init(void) /* Allocate the device array and initialize each one */ zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); - if (!zram_devices) { - ret = -ENOMEM; + if (!zram_devices) goto out_error; - } for (dev_id = 0; dev_id < num_devices; dev_id++) { ret = create_device(&zram_devices[dev_id], dev_id); -- 2.3.0.rc2