Re: [PATCH V2 1/2] ublk_drv: fix error handling of ublk_add_dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
> 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@xxxxxx>
> ---
Reviewed-by: ZiyangZhang <ZiyangZhang@xxxxxxxxxxxxxxxxx>



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux