From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751855AbdF0CC5 (ORCPT ); Mon, 26 Jun 2017 22:02:57 -0400 Received: from sci-ig2.spreadtrum.com ([222.66.158.135]:40758 "EHLO SHSQR01.spreadtrum.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751693AbdF0CC4 (ORCPT ); Mon, 26 Jun 2017 22:02:56 -0400 From: =?utf-8?B?WmhvbmdwaW5nIFRhbiAo6LCt5Lit5bmzKQ==?= To: Arnd Bergmann CC: =?utf-8?B?T3Jzb24gWmhhaSAo57+f5LqsKQ==?= , "Greg Kroah-Hartman" , Linux Kernel Mailing List Subject: =?utf-8?B?UkU6IOetlOWkjTogW1JGQyBQQVRDSF0gY2hhcjogbWlzYzogSW5pdCBtaXNj?= =?utf-8?Q?->list_in_a_safe_way?= Thread-Topic: =?utf-8?B?562U5aSNOiBbUkZDIFBBVENIXSBjaGFyOiBtaXNjOiBJbml0IG1pc2MtPmxp?= =?utf-8?Q?st_in_a_safe_way?= Thread-Index: AQHS7l9tD7gZL09yLUqhZDhhbDen76I2Y98AgACdGHD//4uKAIAAmgL4//+CfgCAAUJAYA== Date: Tue, 27 Jun 2017 02:02:13 +0000 Message-ID: <8f919e212d5149e286422d58a5732356@SHMBX02.spreadtrum.com> References: <20170626093123.23838-1-orson.zhai@spreadtrum.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.1.253] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-MAIL: SHSQR01.spreadtrum.com v5R22Ek3009630 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v5R24buU009415 Ok, firstly we need to discuss the list usage, for list head we need do initialization, but for list node we don't need initialization at all. And for misc_list head, we use LIST_HEAD to define and initialize it. So I don't know why we put INIT_LIST_HEAD(&misc->list) in function misc_register, any bugs when without it? -----Original Message----- From: arndbergmann@gmail.com [mailto:arndbergmann@gmail.com] On Behalf Of Arnd Bergmann Sent: Monday, June 26, 2017 10:10 PM To: Zhongping Tan (谭中平) Cc: Orson Zhai (翟京); Greg Kroah-Hartman; Linux Kernel Mailing List Subject: Re: 答复: [RFC PATCH] char: misc: Init misc->list in a safe way On Mon, Jun 26, 2017 at 4:00 PM, Zhongping Tan (谭中平) wrote: > hi Arnd: > Another way to describe this question, misc_register shouldn't modify > the member of the miscdevice especially when return error. Let the caller to ensure the list have been initialized, or when return error, please don't initialize the list. Why not? The caller should only initialize a couple of fields in the structure (name, minor, fops, ...) not never even look at the list entry, which is really internal to the misc_register()/misc_unregister(). Arnd