Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp296039imm; Thu, 7 Jun 2018 19:00:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEqJUNj1DNhM7Pp+4vTlW1QB79jSC1U4wXZp7kJC5Hzgii0+LsYTlf6cOirXdYYV3afl3H X-Received: by 2002:a63:69c4:: with SMTP id e187-v6mr3483627pgc.294.1528423202690; Thu, 07 Jun 2018 19:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528423202; cv=none; d=google.com; s=arc-20160816; b=Do8ywOdH+979F8waAwJrcUwXIhNU01aSe7i8UEPX03rhrSv+D/ooO1/t21cu6EKEWT RqTOyLiBmKLsg2FpUJpoDeNHtP4hc76YN4dhGPndDWcJhTE9X56gXNZ6Yd4WFZxd/tEG SBC9CBOD3GsZzXfCau/0w8vchL5uGFxrIR2Wi8O8q1X2x+NHHfiYg/Uz6PA8AH4kRfx5 1VIGgRi/RHt48Veydpi4nGgjsRbtYxwIbvaYK3q+KtD/3DOAsj5kH4XjYBD1DHnOOPrl UXhujjmnwq/mfMlEGDQAg9HXSkIz43xrQnjRG2oJzDS8pzzVh1BCYIVwqOB0dKISaoIY vwNw== 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=Ruutcu9EhKCBp7dkz3Rk+DHZ+bFu8QaATXN72AXe96tI3zeNViMY3AtXMevFo2CIXS JAIbVfRkAHFNyQVN0hN9FUgAXsoFJVoIbih3ZREq+XUxY/J7yTSYwvt1RHFI+D7u5u9d SZTWtid19DycvD3xIVq2BIQfzruWXLu2w5jBOeQnJNe6pdxVXJ4cyR9LQ1mz3AInU502 fnS4VAYyLasF6FugCddBb71OuEeL2motniM0HLBeUvwgn9nIzaFeoYfVw5GpR8eZuUj/ UCEIeFc7lZ+U7BMqfD39mruQTmVT7mG798nJ0o9JHEh2FwaVJjc6ZFVaNp/YkNcO2Pv0 CRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=i41NT58w; dkim=pass header.i=@codeaurora.org header.s=default header.b=o98tDozC; 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 f9-v6si51530889plo.568.2018.06.07.18.59.48; Thu, 07 Jun 2018 19:00:02 -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=i41NT58w; dkim=pass header.i=@codeaurora.org header.s=default header.b=o98tDozC; 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 S1752661AbeFHB7X (ORCPT + 99 others); Thu, 7 Jun 2018 21:59:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53808 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752268AbeFHB7V (ORCPT ); Thu, 7 Jun 2018 21:59:21 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4CCAC606FA; Fri, 8 Jun 2018 01:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528423161; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=i41NT58w6vbNSQIoTMU3hBEve/EFdlkxfL75cPtzFQFdvnJOyMY9m2XravBpSSEvI nLJx2Mp3W7CSmgpnm1rmh372sE7tg5ORxUNgiuDH17IQrLpoMkYNixadoYHacImanG 3sCaRZzDV/clf+z7twJm6JAGcDQSGGsrgL/QCFi4= 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 920F1606FA; Fri, 8 Jun 2018 01:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1528423160; bh=LfNdJIt6pzTNRXJmPb2LKUMFl7qx3gRraSWxSOMojpc=; h=From:To:Cc:Subject:Date:From; b=o98tDozCzR8HByvrkGa9txL18zcRb+8oUar1SLgJnOI/JrWFKopPZ05VJGXxmDVDU V1MSvr51TiYw3DHmA6t8oa1HAEayjrrvIW1z01GP5FJK0S62W85T8t8G4sllmR8wJV tYFx2kN7WtpIVf0WvxFOg0btSfQXk+TueYHFZZWw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 920F1606FA 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] component: enhance handling of devres group for master Date: Thu, 7 Jun 2018 18:59:18 -0700 Message-Id: <1528423158-27429-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