Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp413634pxk; Thu, 3 Sep 2020 03:10:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYYaeqq6BYJa8Emken6BTsqApeETc1i2U69Y73bu7PbSp53moWwTg5xKi+Zu7owgEF1+ka X-Received: by 2002:aa7:c693:: with SMTP id n19mr2305847edq.101.1599127816857; Thu, 03 Sep 2020 03:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599127816; cv=none; d=google.com; s=arc-20160816; b=pB4tPaw06jUtq1QXkvqlgxgLJnxr6PdDTudtj6XDCsgiHX/AoWWgJ1CdwLaJAzfxnc C3saRYOZyQKfhYKp/gmh7GGqC9+k+SRP6YIbEG4A2kpE0OZsTBX6iwNiDoGXaXXw85X7 w3ZTgJJDqbGa7eHeVoM77VI/xwk21vkS5y07/8wGMGB7L8nacuLBqPnAKDp+OvxSLl04 s8eL08WVWD8Nn448ncqr2I8jQUz0nW5O/r5GDP+FDVpmU3rJZXe4hvx82BPpFxcG4ACU J5LmvQs6bz4S+spiseEG+I2lUKmY/bAGZFT0kgM8lStd0JL59kHHb5hRsJ91Pohe8o6r pxMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=7ns1zVlmF+pwrGH9GOZCksJLi0dT9SO4rihgWhgyS68=; b=l7MXUGeoUo9HDUQqYgKFup1wadKtQGTnij2Na+NopWWhlKGsNpf1/kq0OoMHPbZUhd LIGv+CbpCvuH0dMjT+23Vy01VSIU84AFG5DuZb4JULQjMAVovvewmuAA9yJmb//Y1Yej 6GsG9S+hsrU6Nf5EZsgLVArFC4aZo7Pvdm3qANzS5V1zLyeLTNNjZFo08qdScmqVLuG0 At/gHRFPSXEN6wojlypVpk/Q5uucqxsbzEMUt/nsopToqMqBhTTKNGqR9LqQz6cir2Zf 0+L5X/2lx9lVdMVD3CCFKP2QBI35EEwI86lQsEnP9UMxZ1venZbLTBhvsrXM4Ubufhhc JQhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZIftqY/c"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si1661151ejf.380.2020.09.03.03.09.53; Thu, 03 Sep 2020 03:10:16 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="ZIftqY/c"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbgICKJT (ORCPT + 99 others); Thu, 3 Sep 2020 06:09:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbgICKJQ (ORCPT ); Thu, 3 Sep 2020 06:09:16 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A80C061244; Thu, 3 Sep 2020 03:09:15 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id k15so2519479wrn.10; Thu, 03 Sep 2020 03:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7ns1zVlmF+pwrGH9GOZCksJLi0dT9SO4rihgWhgyS68=; b=ZIftqY/cOwubsKafsp3NW2i/rOoNtGD2RFfTOSEM8SHZyTef5VCKOJOUZaczY0oV9q nqgYFXGgPwTXZvKjpzcWB4bdH3gFOj1gMkJoMF5uIXnot13uQH3e4nZWv9tvSRNOh83h 6OJizdH/oW72cYRucpa5jxu6ysQiMn2rq7ApdMnMcQTFARhyQxrjt6VdZn4TuhZDttfY WGJyoITTTu0ILEjsItIEzEjAzMtwUr2kQEWxLM8uUyQ22Q55UReKnfM30ZBfElZBVNYr 2Jowy0eiRgZSDLBEutYJa2c+sEL4g5+qFYuBI5xIhteHzq1/J6Nf56H+Ib4NsUhDhoXk MHcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7ns1zVlmF+pwrGH9GOZCksJLi0dT9SO4rihgWhgyS68=; b=i5F8sce92/LtgiSaYx4pPwX5Jt0xDWazQ1uyvz4sXQUmq27xYE6G1H333rtXpsg1Tf 5FTvFkee5scJvghAh1P7tYSU82KczkwGXgeZAZWLr8wqGP1Sa3L3fZR+w2LC5wj99vvw k541Htf6Bag88Nt98ALwxA4H4ip2HcjUcLO+o8A9W6j7bJ0zseaAAmHP8sP9w//N/5G8 l4uQ4xxYFswblzrDwwV1pmeNeDNyj1wxpN/XXd7bHL6CGGjy5iDn3sU2qqDr13gaANZ+ EFoCQN7OQpYmChWosc4sPxrahWZ9E9uwaJ2N0ecBptlGZqKucZ0l/hnaOV9tMX7jv2+7 v3/Q== X-Gm-Message-State: AOAM530bukb0mQYc8fo3Chr1+hVu2fB20gFXjSfUgsV0jRZ58T0HYma4 ZxY4xIvEdMwg8aC3O6Jxu4A= X-Received: by 2002:adf:f042:: with SMTP id t2mr1529695wro.385.1599127754478; Thu, 03 Sep 2020 03:09:14 -0700 (PDT) Received: from medion (cpc83661-brig20-2-0-cust443.3-3.cable.virginm.net. [82.28.105.188]) by smtp.gmail.com with ESMTPSA id v3sm3541805wmh.6.2020.09.03.03.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 03:09:14 -0700 (PDT) From: Alex Dewar X-Google-Original-From: Alex Dewar Date: Thu, 3 Sep 2020 11:09:12 +0100 To: Alex Dewar Cc: Ohad Ben-Cohen , Bjorn Andersson , Loic Pallardy , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] remoteproc: core: Free rvdev on error path Message-ID: <20200903100912.6op2fs6olrtlckr2@medion> References: <20200903100142.57117-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200903100142.57117-1-alex.dewar90@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2020 at 11:01:42AM +0100, Alex Dewar wrote: > In rpoc_handle_vdev(), rvdev is not freed properly on the error path and > one of the labels is misnamed. Fix this up. Actually, don't apply this. I didn't realise that device_unregister already frees memory. Sorry for the noise! > > Fixes: 086d08725d34 ("remoteproc: create vdev subdevice with specific dma memory pool") > Signed-off-by: Alex Dewar > --- > drivers/remoteproc/remoteproc_core.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index d4bd71f87b03..84dea43d196e 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -531,7 +531,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, > rvdev->dev.parent = &rproc->dev; > ret = dma_copy_dma_range_map(&rvdev->dev, rproc->dev.parent); > if (ret) > - return ret; > + goto free_rvdev; > rvdev->dev.release = rproc_rvdev_release; > dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); > dev_set_drvdata(&rvdev->dev, rvdev); > @@ -539,7 +539,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, > ret = device_register(&rvdev->dev); > if (ret) { > put_device(&rvdev->dev); > - return ret; > + goto free_rvdev; > } > /* Make device dma capable by inheriting from parent's capabilities */ > set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); > @@ -556,7 +556,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, > for (i = 0; i < rsc->num_of_vrings; i++) { > ret = rproc_parse_vring(rvdev, rsc, i); > if (ret) > - goto free_rvdev; > + goto unregister_dev; > } > > /* remember the resource offset*/ > @@ -581,8 +581,10 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, > unwind_vring_allocations: > for (i--; i >= 0; i--) > rproc_free_vring(&rvdev->vring[i]); > -free_rvdev: > +unregister_dev: > device_unregister(&rvdev->dev); > +free_rvdev: > + kfree(rvdev); > return ret; > } > > -- > 2.28.0 >