Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1393424

Re: [PATCH] block: initialize hd_stuct's reference before assigning it

From Hannes Reinecke <hare@suse.de>
Newsgroups linux.kernel
Subject Re: [PATCH] block: initialize hd_stuct's reference before assigning it
Date 2016-05-03 15:50 +0200
Message-ID <ruIS5-Hw-13@gated-at.bofh.it> (permalink)
References <ruIIr-Cs-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 05/03/2016 03:38 PM, Johannes Thumshirn wrote:
> Inititialize the hd_struct's perpcu reference before assigning the hd_struct
> to the partition table list.
> 
> This fixes a race which could be triggered using a simple partition
> creation/deletion loop with virtio-blk on aarch64.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  block/partition-generic.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/block/partition-generic.c b/block/partition-generic.c
> index 5d87019..aa5b83a 100644
> --- a/block/partition-generic.c
> +++ b/block/partition-generic.c
> @@ -361,6 +361,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
>  			goto out_del;
>  	}
>  
> +	err = -ENOMEM;
> +	if (hd_ref_init(p))
> +		goto out_free_info;
> +
>  	/* everything is up and running, commence */
>  	rcu_assign_pointer(ptbl->part[partno], p);
>  
> @@ -368,8 +372,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
>  	if (!dev_get_uevent_suppress(ddev))
>  		kobject_uevent(&pdev->kobj, KOBJ_ADD);
>  
> -	if (!hd_ref_init(p))
> -		return p;
> +	return p;
>  
>  out_free_info:
>  	free_part_info(p);
> 
Suggested-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>

:-)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] block: initialize hd_stuct's reference before assigning it Johannes Thumshirn <jthumshirn@suse.de> - 2016-05-03 15:40 +0200
  Re: [PATCH] block: initialize hd_stuct's reference before assigning  it Hannes Reinecke <hare@suse.de> - 2016-05-03 15:50 +0200
  Re: [PATCH] block: initialize hd_stuct's reference before assigning  it Johannes Thumshirn <jthmshirn@suse.de> - 2016-05-06 12:30 +0200

csiph-web