public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Johannes Thumshirn <jthumshirn@suse.de>, Jens Axboe <axboe@fb.com>
Cc: linux-block@vger.kernel.org,
	Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [PATCH] block: initialize hd_stuct's reference before assigning it
Date: Tue, 3 May 2016 15:46:42 +0200	[thread overview]
Message-ID: <5728ABC2.5060905@suse.de> (raw)
In-Reply-To: <1462282683-17664-1-git-send-email-jthumshirn@suse.de>

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)

  reply	other threads:[~2016-05-03 13:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 13:38 [PATCH] block: initialize hd_stuct's reference before assigning it Johannes Thumshirn
2016-05-03 13:46 ` Hannes Reinecke [this message]
2016-05-06 10:26 ` Johannes Thumshirn

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=5728ABC2.5060905@suse.de \
    --to=hare@suse.de \
    --cc=agraf@suse.de \
    --cc=axboe@fb.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@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