Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp82033imm; Wed, 25 Jul 2018 23:08:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchsn8F0qVYwexB8BNgMlhSO9eUziXkTRK1BKYcT6vGrA/gY0mhaZLFCSi9/oA3Z3FBou9t X-Received: by 2002:a63:a543:: with SMTP id r3-v6mr650180pgu.336.1532585302853; Wed, 25 Jul 2018 23:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532585302; cv=none; d=google.com; s=arc-20160816; b=I7HphW8A40AYXZ55zpVmSL5kQamcw4JvSYK/Rt0rzUBy0J9bwhumoh/lX37whraim/ cA9KqZf/wvLv6B956bfkdbnKoHs1Z4H2NiOmte8dNv6ovfGLDZHbWQAqySo22NuuX+Yn hDjxJtlcLdflT7lhGVYZw7kZBqJF3Y4Rdrn+t27ZKpGrmXEpAcmR0cYc6UQQyrnbWki6 dY+sFh6+DsOVIs+vhUaS4JHc9jZxGc9FRVy2jL6u4U9Jv1K1up1+m0Q9a9nz7KD74fug EuO5TeDBUCQ9uwSqHAtKotOGxkAB/AeG5h4KdMUvk8VluCfuMTLBHgdYxHCjmx2zpRSo b8fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=pxAN4CWnSbHgiooBiZwUEj2w8ip886/qTXh279ycZes=; b=BJE0hCLuD6LXJryer29woFU3OZYm1GfJL+BWF43dLyuO/PRfRN76trDUV/G0naSyCD 3VQJU2kc52BMCIcNSXnj+OcUdITNSX2SNSVX6YtqUnVbyzj4DSto3QMWCwUHH97E+RUz w/pll8mU3YHlPjfjTdPRbpxsfUEsFumoz/tX4eYz9Lq9BoF03YrxJR7tiAo7TMjs8s4K jhbxsKYHjbfWfCZ5TGAqVJqxcMlxWw+qZSs5sju3BywrWc2HiKNNTOZX20VQeSP8AW9Y 0e0CO75RAoGSz6cc+XdC+32fOkkdtzunyXYkHqLUsftJB370b9G0PtlSalxSxZqBttyd 4+SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=F2KRRd1m; dkim=pass header.i=@codeaurora.org header.s=default header.b=F2KRRd1m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19-v6si484078plp.52.2018.07.25.23.08.07; Wed, 25 Jul 2018 23:08:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=F2KRRd1m; dkim=pass header.i=@codeaurora.org header.s=default header.b=F2KRRd1m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728772AbeGZHWN (ORCPT + 99 others); Thu, 26 Jul 2018 03:22:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33154 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbeGZHWM (ORCPT ); Thu, 26 Jul 2018 03:22:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A990760B62; Thu, 26 Jul 2018 06:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532585218; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=F2KRRd1mw3ktgoJsqTvr4+2p0XW5Obwi2wGkRLmCHlYZ2a02v/8IdTUz6xH+acIPm Bm/6+bsXSRU/ZwAxE4A8PNrag29IhXcOGzNi5cGRr2A275mHXn0zfJOqpM147OdZ6F 0hyh4SzQnfB2rqXo/ogBNMNj3kD3HQHy/E5CCQaI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: bgoswami@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 02FB6602BC; Thu, 26 Jul 2018 06:06:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532585218; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=F2KRRd1mw3ktgoJsqTvr4+2p0XW5Obwi2wGkRLmCHlYZ2a02v/8IdTUz6xH+acIPm Bm/6+bsXSRU/ZwAxE4A8PNrag29IhXcOGzNi5cGRr2A275mHXn0zfJOqpM147OdZ6F 0hyh4SzQnfB2rqXo/ogBNMNj3kD3HQHy/E5CCQaI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 02FB6602BC Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgoswami@codeaurora.org From: bgoswami@codeaurora.org To: linux@armlinux.org.uk, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, srinivas.kandagatla@linaro.org, Banajit Goswami Subject: [PATCH][RESEND 2] component: enhance handling of devres group for master Date: Wed, 25 Jul 2018 23:06:28 -0700 Message-Id: <1532585188-7831-1-git-send-email-bgoswami@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Banajit Goswami The devres group opened for a master is left open-ended (without devres_group_close) even after bind() is complete. Similarly, while releasing the devres resources for master, the most recently opened devres group is selected, and released without identifying the targeted group. As the devres group opened before master bind was never closed, there may have unintended consequences of releasing devres resources that were allocated after master bind() function was complete. Change adds a devres_group_close() after bind() call to master, to encapsulate the resources allocated during bind, and then use a group ID to specifically identify the group in release, so that during master unbind, only the resources that are part of that specific devres group, are released. Signed-off-by: Banajit Goswami --- drivers/base/component.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/base/component.c b/drivers/base/component.c index 89b032f..f9ce937 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -155,17 +155,19 @@ static int try_to_bring_up_master(struct master *master, return 0; } - if (!devres_open_group(master->dev, NULL, GFP_KERNEL)) + if (!devres_open_group(master->dev, master, GFP_KERNEL)) return -ENOMEM; /* Found all components */ ret = master->ops->bind(master->dev); if (ret < 0) { - devres_release_group(master->dev, NULL); + devres_release_group(master->dev, master); dev_info(master->dev, "master bind failed: %d\n", ret); return ret; } + devres_close_group(master->dev, master); + master->bound = true; return 1; } @@ -190,7 +192,7 @@ static void take_down_master(struct master *master) { if (master->bound) { master->ops->unbind(master->dev); - devres_release_group(master->dev, NULL); + devres_release_group(master->dev, master); master->bound = false; } } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project