Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp60536pxb; Wed, 30 Mar 2022 23:05:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPb3ESV3gJ/3wb1Hc5WYiosZbpfZ0p47Tv1BrZg4L6fZjqEkuvBYLuY0oR8Ew8FWXZhUSo X-Received: by 2002:a17:907:7f20:b0:6e0:751e:edbb with SMTP id qf32-20020a1709077f2000b006e0751eedbbmr3551804ejc.162.1648706716938; Wed, 30 Mar 2022 23:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648706716; cv=none; d=google.com; s=arc-20160816; b=TGvFLnJkj7w28tp8qT0URBwLbbBekPx6OchSXeAr9WsvQ9K5GqVAA0I54qKAbqgSm8 MLJE8QjxD9fUUzW71WWidrwRA+5Hq1/red9yr7rw3rZZIul9AdMSIFqTWqX7MQjljHQx VT/8+Wmp5uQq9aToO8Tu0NbUHBuo1dVc3g8jBtIAyVDnZPxEyoVEksABGzBb4GgOG9UM EHGjAY9NqNQ22gW+DCW6K7WokGdXKHY11/B2jRm3FpnrHPalanJnmfbXp7snfK3CczG+ 6gALwZKsvKLP6nFnfE/1EGCksKMLLS1SakJxVUl5rd1e1FOng2PJvxkvps6BRwTcs8WF +3XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KYbf7HSV24jrzW2ZtVUEOaLTWz6JVZPXyL3Rs7bbWM0=; b=xG6b7VzbD3kLK/YyooepUS8kpj06qf0MvdtSOTwRyhdAvczJemPj5TLcjsFzDGJHtU ZrLc6bEPBTGSs8Pakv58wymiBbFAkk18+FBSrg8ksobXxhb9ynQHc8JzA4jd0F8cWPfx WDtK6A7M96kPVYH8N0X9F9ecO3qvOCc5TRKTJm0FvL2MlhCXSopKEsu+Q4pmk952Bc/r pRbl3ZW+vZZTDMPT/mtpou0eh5xZ1mCDFTE7FHtmmuvDkoFhW88kWAo4nNOLdRz0gOIg ruGN3LC99A5MvHTaodFsUbnkV0ZSOnQA9acHD5oVTY7fJldh9j2w0RBmOX32qD+P1u/2 fmSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=GVzk+N3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p11-20020a50cd8b000000b00418c2b5be00si22328260edi.226.2022.03.30.23.04.46; Wed, 30 Mar 2022 23:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=GVzk+N3z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbiCaFrL (ORCPT + 99 others); Thu, 31 Mar 2022 01:47:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbiCaFrJ (ORCPT ); Thu, 31 Mar 2022 01:47:09 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48A4D1005; Wed, 30 Mar 2022 22:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=KYbf7HSV24jrzW2ZtVUEOaLTWz6JVZPXyL3Rs7bbWM0=; b=GVzk+N3zwXy8smg2a0hAxoFSWr vlNPRnTm7Z1CH/5DWiTzx54r2Z32DfZQnywgD+6RYOrjqOiE6OWIF0mMOSzZxJKJnd4V3DuyFP/oH jBsg3NpArwXOP8hqFhedNGhb9Zq9QxvatG/Fk8heHlBrfZnyjViW1u0oITuS7+1YfI0bPNEqI/t+e 1lOFGwO0wkNjGz3VMgHT70prYy7YNAXXFRnSj5eby/FVwOtGty/t1J3IGGvuEaEyt9HwodJYRbWI+ LI45kP425fWQ90+/mjRbGuBpqXtNxJblFkvpnW3iaxPi9p5WjUG6fQ2jz7CYmT+hKJC1RFfaC3soB S0Jobl1Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nZncO-000jlX-Jw; Thu, 31 Mar 2022 05:45:12 +0000 Date: Wed, 30 Mar 2022 22:45:12 -0700 From: Christoph Hellwig To: Dan Carpenter Cc: Wenchao Hao , fmdefrancesco@gmail.com, axboe@kernel.dk, jejb@linux.ibm.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, martin.petersen@oracle.com, syzbot+f08c77040fa163a75a46@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, linfeilong@huawei.com Subject: Re: [PATCH] scsi: sd: call device_del() if device_add_disk() fails Message-ID: References: <20220329154948.10350-1-fmdefrancesco@gmail.com> <20220331152622.616534-1-haowenchao@huawei.com> <20220331054156.GI3293@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220331054156.GI3293@kadam> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > The temptation was to call device_unregister() which is a combined > device_del(); device_put(); but when the device_initialize() and > device_add() are called separately, then I think it is more readable to > call del and put separately as well. I think we should also consolidate the initialization side. Using device_register and device_unregister would have prevented this bug and I should have switched to that before refactoring the code.