Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp791579imm; Mon, 2 Jul 2018 23:25:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc0YbcdKwf1+x5YG2QLOlI5mI98m82iyTshiYmQ0XiOp5v3ZhentEo8gjaydYjDmCAIKWVT X-Received: by 2002:a62:1894:: with SMTP id 142-v6mr22748849pfy.49.1530599106130; Mon, 02 Jul 2018 23:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530599106; cv=none; d=google.com; s=arc-20160816; b=sbocw+IW+01+EUbwIx5zz0LjxKD2NKSKCpu1VlyItigpUi1hIJfYzBQ9RiroPI5yGc CXtbDF0mSJl0pBs6+1gDEAWLOHQtIx9FkIdrXyauyBDS0iSxPZBVgnyqfFSos8FjaCch jGcVsS9I52vi4+I+CtCuhMJgKWHi8pp8bsiwQHbDrf+mUeDPcQS2OINR8nb76/u7/GZI yKDODihdN+tdlpa6Ye/upzi4/ZMBII2lFkgZtQVw+D7fl2XBbkcO//7wZpbahdcU607o qtVjlsn7Npa70KuRL9COvakK59x3Tu13U1FxU0IpWudixVigbDN7vGaAMYTotXKymh+d uXTQ== 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=06qNQf8zlu50Pi3EzdxSQTqcmatGh8rukeeo0EMAaIU+VEipNsLSgkdlOk8iBPgZus RJRmEaTz36lXb4BSK1UXW5m53RhHVDN6eRnRXkw33yApMFYPnLK37iXXLBc2wiAhl6oE OY/ISnm03+i1k1A6eVLJGEavxiOL2mzpzfZUXqwOBsm6NSP4offCQNyiGyrTwOABm6yX Poz8KhAmq2mhM1K3fRHVlr7uR8her6OP7PQe+C5IWb9FW+CsbUT1KijAIe8gKOKYQHrC d34FBasPagqRGJgnZRCkBzMqHL0O5vpBQjoGcw8Hi4hI9wCuGFReCIynAGvPbJwMVrvR 7wfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="Im+/lU1P"; dkim=pass header.i=@codeaurora.org header.s=default header.b="Im+/lU1P"; 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 p3-v6si411358plr.131.2018.07.02.23.24.51; Mon, 02 Jul 2018 23:25:06 -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="Im+/lU1P"; dkim=pass header.i=@codeaurora.org header.s=default header.b="Im+/lU1P"; 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 S933057AbeGCGYN (ORCPT + 99 others); Tue, 3 Jul 2018 02:24:13 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58386 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932778AbeGCGYM (ORCPT ); Tue, 3 Jul 2018 02:24:12 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B46E460B25; Tue, 3 Jul 2018 06:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530599051; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=Im+/lU1PRDuZ2BDDdQi/Dy9PaeP47PNs2wxA/BRvdxEgr3Laiakvrg8Jr4sGzT4f3 2JfFEzvMrWcaCEUISF7f1YaUaZL1S5RntLW2XTzUAR91al4QTI1xuK5UhoZeXxH2/0 9bWcIjg6XwdvblFPaXKw9ZdfyZlUmSZSftnghIG4= 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 5156660274; Tue, 3 Jul 2018 06:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530599051; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=Im+/lU1PRDuZ2BDDdQi/Dy9PaeP47PNs2wxA/BRvdxEgr3Laiakvrg8Jr4sGzT4f3 2JfFEzvMrWcaCEUISF7f1YaUaZL1S5RntLW2XTzUAR91al4QTI1xuK5UhoZeXxH2/0 9bWcIjg6XwdvblFPaXKw9ZdfyZlUmSZSftnghIG4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5156660274 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: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, srinivas.kandagatla@linaro.org, Banajit Goswami Subject: [PATCH][RESEND] component: enhance handling of devres group for master Date: Mon, 2 Jul 2018 23:24:09 -0700 Message-Id: <1530599049-16212-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