From: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
To: Christoph Hellwig <hch@infradead.org>, Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [PATCH V2 1/2] ublk_drv: fix error handling of ublk_add_dev
Date: Fri, 22 Jul 2022 15:35:13 +0800 [thread overview]
Message-ID: <0e564701-a5fd-e31f-17fd-8d6a96f736ec@linux.alibaba.com> (raw)
In-Reply-To: <YtpA70BmGMDrdnsU@infradead.org>
On 2022/7/22 14:17, Christoph Hellwig wrote:
> On Thu, Jul 21, 2022 at 10:48:07PM -0700, Christoph Hellwig wrote:
>> I think __ublk_destroy_dev just needs to go away in that form.
>> Also I'd much rather do the copy_to_user before the ublk_add_chdev
>> as that means we never remove a devic already marked life due to a
>> failure. Something like the patch below, which will need testing first
>> before I'd dare to submit it:
>
> Improved and tested version:
>
> ---
> From 49ba6d0c5788ea9d3a6ef88d910b702152f5d75a Mon Sep 17 00:00:00 2001
> From: Christoph Hellwig <hch@lst.de>
> Date: Fri, 22 Jul 2022 07:38:59 +0200
> Subject: ublk_drv: fix error handling of ublk_add_dev
>
> __ublk_destroy_dev() is called for handling error in ublk_add_dev(),
> but either tagset isn't allocated or mutex isn't initialized.
>
> So fix the issue by letting replacing ublk_add_dev with a
> ublk_add_tag_set function that is much more limited in scope and
> instead unwind every single step directly in ublk_ctrl_add_dev.
> To allow for this refactor the device freeing so that there is
> a helper for freeing the device number instead of coupling that
> with freeing the mutex and the memory.
>
> Note that this now copies the dev_info to userspace before adding
> the character device. This not only simplifies the erro handling
> in ublk_ctrl_add_dev, but also means that the character device
> can only be seen by userspace if the device addition succeeded.
>
> Based on a patch from Ming Lei.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Reviewed-by: ZiyangZhang <ZiyangZhang@linux.alibaba.com>
next prev parent reply other threads:[~2022-07-22 7:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 5:09 [PATCH V2 0/2] ublk_drv: make sure that correct flags(features) returned to userspace Ming Lei
2022-07-22 5:09 ` [PATCH V2 1/2] ublk_drv: fix error handling of ublk_add_dev Ming Lei
2022-07-22 5:48 ` Christoph Hellwig
2022-07-22 6:17 ` Christoph Hellwig
2022-07-22 7:35 ` Ziyang Zhang [this message]
2022-07-22 5:58 ` Ziyang Zhang
2022-07-22 5:09 ` [PATCH V2 2/2] ublk_drv: make sure that correct flags(features) returned to userspace Ming Lei
2022-07-22 5:50 ` Christoph Hellwig
2022-07-22 7:30 ` Ming Lei
2022-07-22 8:09 ` Christoph Hellwig
2022-07-22 6:00 ` Ziyang Zhang
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=0e564701-a5fd-e31f-17fd-8d6a96f736ec@linux.alibaba.com \
--to=ziyangzhang@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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