From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846AbdBUPnM (ORCPT ); Tue, 21 Feb 2017 10:43:12 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:41969 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbdBUPnD (ORCPT ); Tue, 21 Feb 2017 10:43:03 -0500 Date: Tue, 21 Feb 2017 16:42:54 +0100 From: Peter Zijlstra To: Elena Reshetova Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, gregkh@linuxfoundation.org, perex@perex.cz, tiwai@suse.com, Hans Liljestrand , Kees Cook , David Windsor Subject: Re: [PATCH] sound: convert snd_seq_subscribers.ref_count from atomic_t to refcount_t Message-ID: <20170221154254.GG6515@twins.programming.kicks-ass.net> References: <1487690830-30277-1-git-send-email-elena.reshetova@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487690830-30277-1-git-send-email-elena.reshetova@intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 21, 2017 at 05:27:10PM +0200, Elena Reshetova wrote: > diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c > index fe686ee..1ca896b 100644 > --- a/sound/core/seq/seq_ports.c > +++ b/sound/core/seq/seq_ports.c > @@ -520,7 +520,6 @@ static int check_and_subscribe_port(struct snd_seq_client *client, > else > list_add_tail(&subs->dest_list, &grp->list_head); > grp->exclusive = exclusive; > - atomic_inc(&subs->ref_count); > write_unlock_irq(&grp->list_lock); > err = 0; > > @@ -570,7 +569,6 @@ int snd_seq_port_connect(struct snd_seq_client *connector, > return -ENOMEM; > > subs->info = *info; > - atomic_set(&subs->ref_count, 0); > INIT_LIST_HEAD(&subs->src_list); > INIT_LIST_HEAD(&subs->dest_list); > > @@ -587,6 +585,7 @@ int snd_seq_port_connect(struct snd_seq_client *connector, > if (err < 0) > goto error_dest; > > + refcount_set(&subs->ref_count, 2); > return 0; > > error_dest: > @@ -613,7 +612,7 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector, > /* look for the connection */ > list_for_each_entry(subs, &src->list_head, src_list) { > if (match_subs_info(info, &subs->info)) { > - atomic_dec(&subs->ref_count); /* mark as not ready */ > + refcount_dec(&subs->ref_count); /* mark as not ready */ > err = 0; > break; > } This looks dodgy... someone should look hard at this.