Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1110931pxu; Thu, 8 Oct 2020 03:44:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBrUsNZ3QdcquKFs34JkZiDHyAo8CzrYQs5DSm9HvzagV3V5yjTiKusbu1qhyEOLRihAD3 X-Received: by 2002:a17:907:42d6:: with SMTP id ng6mr7687453ejb.464.1602153850236; Thu, 08 Oct 2020 03:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602153850; cv=none; d=google.com; s=arc-20160816; b=C1/bEzuX8N9c/i4YOqnYhyHPFH1Lueb2xZj6tIdie/TaxFvDpBUDbi2hvbzmz3tNH2 ASfUvk+UBVMNgA/DHcwoxshvwvCHDhUVOQoFBlm9PRm9lnZsdcmVUDQPVX91P0M60yH+ 52aCcdH8A22Wj3Z1fcX7kgMsNx2zYSJ9vqPWZPwM/zlMXZx/9YVS63fRfJBDWAMf3mv3 HF+xtVg9GU6b6/niKL2/z4f0vm0+2/4Kv8cvgvOx6/FD/GY4S+XXtDa/r/LndJe9YH+s ds5mwIttKhgxU2xjOc7T4XkHjPcTxerEu5lrCSR6JE1BCjfeVpdSr1ZfprQbqfiR1684 6PPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7qhnvaXmyAwIIGWfVIxEGDx+tV+e7f2WtsCpzX1u3KE=; b=IPTrqBRjhFzUYQ7oXYnkMSj/mDwdq3hc8RQMK8VHHn7aMhcg0IQJIPGYbKppBYfezD ZxMKzWYEhaZzMTHKFi8QBXAR2vbI1GRrL5I1B5BTgQyUd+MaeEaC/qIJehGiM6wBmB4I nh2ypZdtRiwGklcp7ZmUDOUAyosxp/HLQJA/uAW8fEsK9toDog/vWKH9nIm9Au1TRz/w /3R53A8pXlGibA0HfaDB+zZaoFl+Os47wc1HEJEd7T3UUqOHb8oRzBMFg8LLXdTLasxU 97QwQetbAYFaE8rgTOuI8iCCNqETqYn7QHsmb3SaNHCfRnLxhKFvbNqZfc+hs5VO/b7f RLlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr21si4155304ejc.186.2020.10.08.03.43.47; Thu, 08 Oct 2020 03:44:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728919AbgJHIuD (ORCPT + 99 others); Thu, 8 Oct 2020 04:50:03 -0400 Received: from foss.arm.com ([217.140.110.172]:44536 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728550AbgJHIuD (ORCPT ); Thu, 8 Oct 2020 04:50:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B2171042; Thu, 8 Oct 2020 01:50:02 -0700 (PDT) Received: from bogus (unknown [10.57.53.233]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C6E673F70D; Thu, 8 Oct 2020 01:50:00 -0700 (PDT) Date: Thu, 8 Oct 2020 09:49:54 +0100 From: Sudeep Holla To: Jassi Brar Cc: Jassi Brar , Viresh Kumar , ALKML , DTML , LKML , Vincent Guittot , Frank Rowand , Bjorn Andersson , Rob Herring , Rob Herring Subject: Re: [PATCH 4/4] mailbox: arm_mhu: Add ARM MHU doorbell driver Message-ID: <20201008084954.f45lospaagookbwp@bogus> References: <20200928114445.19689-1-sudeep.holla@arm.com> <20200928114445.19689-5-sudeep.holla@arm.com> <20201007114034.rkiujybiknaedy7m@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 07, 2020 at 10:43:19AM -0500, Jassi Brar wrote: > On Wed, Oct 7, 2020 at 6:40 AM Sudeep Holla wrote: > > > > On Fri, Oct 02, 2020 at 02:42:37PM -0500, Jassi Brar wrote: > > > On Mon, Sep 28, 2020 at 6:45 AM Sudeep Holla wrote: > > > > > > > + > > > > +static void mhu_db_shutdown(struct mbox_chan *chan) > > > > +{ > > > > + struct mhu_db_channel *chan_info = chan->con_priv; > > > > + struct mbox_controller *mbox = &chan_info->mhu->mbox; > > > > + int i; > > > > + > > > > + for (i = 0; i < mbox->num_chans; i++) > > > > + if (chan == &mbox->chans[i]) > > > > + break; > > > > + > > > > + if (mbox->num_chans == i) { > > > > + dev_warn(mbox->dev, "Request to free non-existent channel\n"); > > > > + return; > > > > + } > > > > + > > > > + /* Reset channel */ > > > > + mhu_db_mbox_clear_irq(chan); > > > > + chan->con_priv = NULL; > > > > > > > request->free->request will fail because of this NULL assignment. > > > Maybe add a 'taken' flag in mhu_db_channel, which should also be > > > checked before calling mbox_chan_received_data because the data may > > > arrive for a now relinquished channel. > > > > > > > Good point, but the new 'taken' flag will have the same race as con_priv. > > We need a lock here and can we use chan->lock or do you prefer this > > driver maintains it own for this purpose. > > > I meant the con_priv is allocated in mhu_db_mbox_xlate and simply > assigning it NULL leaks memory, if not a crash by some other path. At > least free it before. > Ah right, sorry got confused. Too much reliance on devm_* apis and I didn't realise it was not in probe but in xlate which is mbox_startup path. Fixed now, will post v2 with both issues addressed. -- Regards, Sudeep