From: Eli Billauer <eli.billauer@gmail.com>
To: Ma Ke <make24@iscas.ac.cn>, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3] char: xillybus: Fix error handling in xillybus_init_chrdev()
Date: Sat, 19 Jul 2025 14:26:14 +0200 [thread overview]
Message-ID: <fae36efb-be09-8b60-ff84-db6cb38fc18e@outbound.gmail.com> (raw)
In-Reply-To: <20250718100815.3404437-1-make24@iscas.ac.cn>
On 18/07/2025 12:08, 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.
>
Could you please point at how and why this is "standard kernel
practice"? In my reply to PATCH v2, I pointed out that indeed, in
fs/fuse/cuse.c a failure of cdev_add() leads to a call to cdev_del(),
like you suggested. However, in uio/uio.c the same scenario is handled
by a call to kobject_put(), exactly as in my driver. So which way is
"standard"?
There are indeed kernel-global efforts to align code with a certain
coding style every now and then. Is there any such in relation to this
issue?
Otherwise, please leave this alone. Playing around with error handling
flows is a dangerous business, and can lead to vulnerabilities. One
needs a good reason to do that on code that has been out there for a
while (four years, in this case).
And now, to the patch itself:
> @@ -157,8 +156,6 @@ int xillybus_init_chrdev(struct device *dev,
> device_destroy(&xillybus_class, MKDEV(unit->major,
> i + unit->lowest_minor));
>
> - cdev_del(unit->cdev);
> -
> unregister_chrdev:
> unregister_chrdev_region(MKDEV(unit->major, unit->lowest_minor),
> unit->num_nodes);
Why did you do this? It just adds a memory leak, and it's out of the way
of even trying to fix anything: The only effect this has is that
cdev_del() isn't called on error situations that occur after cdev_add()
has been successful. It has nothing to do with the kobject_put() /
cdev_add() thing, because that case jumps to unregister_chrdev, which is
after this removal.
I have to say, both the language of the patch description as well as the
weird removal of cdev_del() remind me of nonsense ChatGPT does when it's
given tasks related to programming. If you're using AI to suggest
patches, please stop.
Regards,
Eli
prev parent reply other threads:[~2025-07-19 12:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-18 10:08 Ma Ke
2025-07-19 12:26 ` Eli Billauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fae36efb-be09-8b60-ff84-db6cb38fc18e@outbound.gmail.com \
--to=eli.billauer@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®