[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a86086f-5b3b-104c-f06d-4194464d84e3@outbound.gmail.com>
Date: Sun, 20 Jul 2025 10:05:43 +0200
From: Eli Billauer <eli.billauer@...il.com>
To: Ma Ke <make24@...as.ac.cn>, arnd@...db.de, gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
stable@...r.kernel.org
Subject: Re: [PATCH v4] char: xillybus: Fix error handling in
xillybus_init_chrdev()
Hello,
On 19/07/2025 15:17, Ma Ke wrote:
> Use cdev_del() instead of direct kobject_put() when cdev_add() fails.
> This aligns with standard kernel practice and maintains consistency
> within the driver's own error paths.
>
Sorry, to the extent it matters, I'm not acknowledging this.
This is merely a code styling issue, and as far as I know, there is no
"standard kernel practice" on this matter. If such standard practice
exists, the correct way is to prepare a patchset of *all* occurrences of
kobject_put() used this way, and replace them all (e.g. fs/char_dev.c,
uio/uio.c and tty/tty_io.c). Should xillybus_class be included in this
patchset, I will of course ack it, not that it would matter much.
In my opinion, using cdev_del() is incorrect, as you can't delete
something that failed to be added. Practically this causes no problem,
but as a question of style, the kobject_put() call acts as the reversal
of cdev_alloc(). This is formally more accurate, and this is the reason
I chose to do it this way.
But more than anything, I find this patch pointless, unless someone
explains why it has any use. I'm open to new insights.
Regards,
Eli
Powered by blists - more mailing lists