Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1629832pxb; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys5ubVSRhfQot8CEW5hvgSF7gyhU1xT0GQ4UVvDezyQGMKoJRvKJYPNFse/L2XUnI1fh/K X-Received: by 2002:a17:90a:74c6:: with SMTP id p6mr27618534pjl.218.1618221201399; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618221201; cv=none; d=google.com; s=arc-20160816; b=IZ/iv7hR/FH79Xy8G8Qqf8fkWD7+DScyxqutwVwNhveodqRflwpgwSy0LDUCLZPc+c nsmSSX2g1w/+Hp9rclRVCIJwHS87IgpRPOsPyfh99vgiwbKXd68VrOHKKpURWbS5516C CuczgrDDVbMqK99hCpi4O0RWp5hN9ISlJE7c+WtFFpQqOSJKznESGu23e3LSF2LY0pu8 BD3xwax8oHaWfzZcRF8O3NOqr5kNsEpSl0HVgcLP5BdJjukdn3P5jcOJtWHG1jmdJ9a5 3394b/tfFVhCqu1LTCEsDkFhjGzkCY6JgZP3TCZsIAX+5MLwqTda9uSADbRmrOJelIRM muQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PLp5f/zBf2/n9kEyaoxXbPDnZb4h4E+81feMsgx0tZc=; b=rQ4YfFo/AUo+zdHmqHQG+VoIx3T68OTAdzoQYt54q0M2CmVfHRq0/sG9UOJM1YmC28 quiU0h38UfQe47/WA/PO77Fr/aBkCWVCvyENtpwHBGE7p33B72Md+QygRADRFycR57cG MftVfGwvPeneiXvWfkyoOmkosV8mcUQklhaIC0O3JkPbtS5DFt19GmCJ8z4yW7KCiTVK 9vJvA/Vpr/ygu1etg+rdHO/rMiVPoby1woUFQsXCMW0hwRhcb8cKodNIYYcKbBjjLzDy 2c9ksK/GojLbaqFnIoQRWeIpghKS3t2q+Sdekhn3UGok8UygnoEsKG2u1FOsfIpkTRZC 3ckg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JgBlzxne; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si11914387pjn.131.2021.04.12.02.53.08; Mon, 12 Apr 2021 02:53:21 -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=@kernel.org header.s=k20201202 header.b=JgBlzxne; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242573AbhDLJua (ORCPT + 99 others); Mon, 12 Apr 2021 05:50:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:54966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241169AbhDLJhO (ORCPT ); Mon, 12 Apr 2021 05:37:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E057F61245; Mon, 12 Apr 2021 09:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618220210; bh=4ZsdKcat8lLSa2EXVUcjSKTmEmymgiIb2x6FsMboVJY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JgBlzxneLvgrX8ejKkh4Z1Zjs4l8HIRC3HWKcf/FUOMv9n52poTOXoUswgJcXmf/0 w7IqUcYL5FZVdCoL9AqwzrYOIBNTGYHcMOt0/Kmng9fzIVXMuH5d1IuVZ6Dve2KiwM Jg9pGzH64gjewBaCAzbZdNYpYN9OIgCMI1cvWO7I9Nvwpn7VMSOMP5hyJN79ZnUT0R BVEdp56F6HnOGkXzVIAcKIgWG2lOd7GhMbTJLUNGkygGYrtxRSrQnUNM9xbxcl8gEz XK5uG7T3BT0BZaMDH8qPcYZj5I3sbwQGuJEEI9NGoDW4KTJZ2hhGwIlhFdxr7Zil87 toHUeCxZ/I0sA== Date: Mon, 12 Apr 2021 15:06:46 +0530 From: Vinod Koul To: Lv Yunlong Cc: dave.jiang@intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] dma: Fix a double free in dma_async_device_register Message-ID: References: <20210331014458.3944-1-lyl2019@mail.ustc.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331014458.3944-1-lyl2019@mail.ustc.edu.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30-03-21, 18:44, Lv Yunlong wrote: > In the first list_for_each_entry() macro of dma_async_device_register, > it gets the chan from list and calls __dma_async_device_channel_register > (..,chan). We can see that chan->local is allocated by alloc_percpu() and > it is freed chan->local by free_percpu(chan->local) when > __dma_async_device_channel_register() failed. > > But after __dma_async_device_channel_register() failed, the caller will > goto err_out and freed the chan->local in the second time by free_percpu(). > > The cause of this problem is forget to set chan->local to NULL when > chan->local was freed in __dma_async_device_channel_register(). My > patch sets chan->local to NULL when the callee failed to avoid double free. Applied after fixing subsystem name, thanks -- ~Vinod