From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754066Ab0IFXla (ORCPT ); Mon, 6 Sep 2010 19:41:30 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:61507 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657Ab0IFXlZ (ORCPT ); Mon, 6 Sep 2010 19:41:25 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=sfQONpfnnOPclfHvXdgPvsyw7a5LclD7fistthQyASKUm3Ai4xaUXRtm9tgZEjCaRV AU9VdWR03ntGuKYCOhqkKkH2KIIVCUHXkl6L/dfiLKA7W0P5N82bNrbhaeSYSMGwwuPj mQdJZ2g4p0STWMqUYStJenZIsP3BELtVBVZhM= Date: Mon, 6 Sep 2010 16:41:19 -0700 From: Dmitry Torokhov To: "Nicholas A. Bellinger" Cc: linux-scsi , linux-kernel , Douglas Gilbert , Richard Sharpe , Christoph Hellwig , FUJITA Tomonori , Mike Christie , Hannes Reinecke , James Bottomley , Greg KH Subject: Re: [PATCH] scsi_debug: Convert to use root_device_register() and root_device_unregister() Message-ID: <20100906234119.GA20589@core.coreip.homeip.net> References: <1283812340-21132-1-git-send-email-nab@linux-iscsi.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1283812340-21132-1-git-send-email-nab@linux-iscsi.org> User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 06, 2010 at 03:32:20PM -0700, Nicholas A. Bellinger wrote: > static int __init scsi_debug_init(void) > { > unsigned long sz; > int host_to_add; > int k; > - int ret; > + int ret = 0; > Please do not initialize error condition with success; when adding additional initialization it makes easy to miss assigning proper return value (as you seem to have) and return success in case of failure. > switch (scsi_debug_sector_size) { > case 512: > @@ -3352,10 +3343,9 @@ static int __init scsi_debug_init(void) > map_region(0, 2); > } > > - ret = device_register(&pseudo_primary); > - if (ret < 0) { > - printk(KERN_WARNING "scsi_debug: device_register error: %d\n", > - ret); > + pseudo_primary = root_device_register("pseudo_0"); > + if (!(pseudo_primary)) { root_device_register() returns ERR_PTR-encoded error codes, you should do: if (IS_ERR(pseudo_primary)) { printk(KERN_WARNING "scsi_debug: root_device_register() error\n"); ret = PTR_ERR(pseudo_primary); goto free_vm; } Same goes for your other patch. Thanks. -- Dmitry