From patchwork Fri Nov 3 20:08:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 117959 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp139415qgn; Fri, 3 Nov 2017 13:09:00 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R74IciVDQPDIrsLUdEtSzVzDVvg/Vn1norWIrGiglFDwKVHEUY+Edaj0hNdsm7UqZMvIZM X-Received: by 10.99.178.86 with SMTP id t22mr8195880pgo.382.1509739740671; Fri, 03 Nov 2017 13:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509739740; cv=none; d=google.com; s=arc-20160816; b=Fr1EVk1u5w/ZQXeKDItgzEZvkMfOskNHJ4efxvVTaI7o9s92CZB9NpAUPnr5HnDsV0 w+e0BzlSPLKqm45dVundr8DvbSJcV1rucnz5oUJzzvC4MiiuTsB3AXq3sCz9SD6BcyeY dP98zuPk2Z7jsSUT6Uof05e4yk+YmvUzkAiUIUyACFD2gjKSSf/wrHLguluF6t0YJQva 1rS38nljLZx1Xi+4f92dFT0LW76I/1qWzuvAwoOuCKkFfec2DFYJkLe+SoLaTzLJn+pL FO2OtRpIvp5bu7mlGRsHOvIrGhoN3QlsK3BruBcsJ9kiiELBx30EH4WOXJaNXlBXIkMB uXdw== 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 :dkim-signature:arc-authentication-results; bh=nTVXvUjixc2p7pXH3alAqGWV0u89VlxwRioFt/EoD7k=; b=naNHuGOBX4H/87LCElxbYUFeRiFnbWdTDUsaLVVLxg+1kU4Nxw0xyqFctAU2MpKnU7 4SoIaHgywx8FC3lhnbbTWhaKGIh1XVzN8/+aXjUNO0/IdXoLALD96vPKC/oWS3JJc0EI o1OUZAcsMd9HmW+VDIgsx8gNezzZ9ScdxlvpdtFLn7akHET188z6zp4HHSduUSoizL+U adHPoejOLkgq4n6OaN1ypDEoSsEsONldsWkS6812D7mMNBBFBQrHgtvTf4I4li4aPfOE hkWV4aB3fMl5yXT4QjsLRAFi6loC9CrHBp/9vyhy2CxyQyFQn2AoIMsL4X3UhGvRe1JH TDnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=w7Rc0/FV; 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 y76si7235180pfd.136.2017.11.03.13.09.00; Fri, 03 Nov 2017 13:09:00 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=w7Rc0/FV; 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 S933614AbdKCUI7 (ORCPT + 26 others); Fri, 3 Nov 2017 16:08:59 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:50362 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752659AbdKCUIy (ORCPT ); Fri, 3 Nov 2017 16:08:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nTVXvUjixc2p7pXH3alAqGWV0u89VlxwRioFt/EoD7k=; b=w7Rc0/FV4T6rqHPx1/iAn/VrS ZhQyShQw9aJY8bQshlp8GcTDWCAvv3Iypzqz3jPxVUxABLhLURPDbaanTWAWrvOkqgQdkXcqcdSJf uK/jubTz1moU870BigYDRJQ0UaAtNaQzD8qrUanmX0q3R58FF37+SecX9tY9bZGFnhRxE=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eAiGq-0000a6-RP; Fri, 03 Nov 2017 20:08:53 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1eAiGq-0002fV-2U; Fri, 03 Nov 2017 20:08:52 +0000 From: Mark Brown To: Baolin Wang Cc: linux-kernel@vger.kernel.org, Mark Brown Subject: [PATCH 1/2] regmap: Also protect hwspinlock in error handling path Date: Fri, 3 Nov 2017 20:08:50 +0000 Message-Id: <20171103200851.10215-1-broonie@kernel.org> X-Mailer: git-send-email 2.15.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The previous patch to allow the hwspinlock code to be disabled missed handling the free in the error path, do so using the better IS_ENABLED() pattern as suggested by Baolin. While we're at it also check that we have a hardware spinlock before freeing it - the core code reports an error when freeing an invalid lock. Suggested-by: Baolin Wang Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.15.0 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index ff6ef6a579c6..5ff549fa880b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1116,7 +1116,8 @@ struct regmap *__regmap_init(struct device *dev, regmap_range_exit(map); kfree(map->work_buf); err_hwlock: - hwspin_lock_free(map->hwlock); + if (IS_ENABLED(REGMAP_HWSPINLOCK) && map->hwlock) + hwspin_lock_free(map->hwlock); err_map: kfree(map); err: From patchwork Fri Nov 3 20:08:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 117960 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp139647qgn; Fri, 3 Nov 2017 13:09:13 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RH5Pb588ofoHXrugYFMkNCemnzhoAHFDCoaCCAqqxX656XPgetVDawZOPsEH9C3YLVf1fu X-Received: by 10.98.32.212 with SMTP id m81mr8729191pfj.227.1509739753786; Fri, 03 Nov 2017 13:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509739753; cv=none; d=google.com; s=arc-20160816; b=t+18aq6qn6/sO2K3kwYI4QqAWdRdv1Q5Jf2GYXiiQLxhQj7Xi7auVhttA5ySpjEcWi 1JCsHO+g1hBUxCMLNSJjVP3RAmPHBlOj3IXDRIlRiVAU75ZUuF85ocFYjbqlc7KxXjlT zosxL2DM02ptuQLLf9TnVeQOx0bqsbqKyWn8RK545g3W5Lvw1Fruk+9HzMJnrH9t7dlR 5ftMDxtfqYIZH9Qj0LG1zwwZR+kEXAt8dcCS0uqyxWeiNfeAQQhoT6r2pxXr4/WYVfNw tNSBxZrbOWYc/PxrVh3rCP5HTAdz80Fz4P0vVrApIDXWnkhV/FNdTNR1x7yKnJ6L7Hzz vz7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3MGkpSkyBbHydmoHjUqyaH/E+Wvj5DM2raWST4kSIjM=; b=awornTXQYGRmRdTlB6bkbG14q2gOPuw/UQ8J/+ZfWWUz/fgrVyJRHrtPR6cMTRUfQt ZAbyAX9ESRPPV8MY3SxJ5/XX7Vah2iWFlWuGPxQg+BDqKwUzE15eIXaXDM0kR4ydZQ73 GWU4Ygmh+P7jegMwyRX39tyoLz35/tlp5W3CAaBY+EmR1NvjRIGXIUek1X/dvnQ111W5 JsR70lTQdmW7sgPN6TtW7p4wkheVf3bT9aD39v5+ZKVKBMJbi6okdwcgCGnu4rlwW0jZ zKdVpp8wpf0D03SSIwWWnfMhHYKRFlh7hCHf13p9U4gTTWRXbcqmf/2+hmKd8pmSLlm3 JXHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=OW0XbWV0; 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 34si5407145plm.300.2017.11.03.13.09.13; Fri, 03 Nov 2017 13:09:13 -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=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=OW0XbWV0; 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 S933510AbdKCUI6 (ORCPT + 26 others); Fri, 3 Nov 2017 16:08:58 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:50370 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756495AbdKCUIy (ORCPT ); Fri, 3 Nov 2017 16:08:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3MGkpSkyBbHydmoHjUqyaH/E+Wvj5DM2raWST4kSIjM=; b=OW0XbWV0i+r/OophyrM1cXWqt G7T10xhKTLF6YDMjmv4o2ExdfZr/n2vy6vwe8gutIXuD6pKn0FgrgMdHCR1Oosa+DsNQV2ZoQKQiI cReMb9/+HqQ9jyMTDBQ9yk4wcEEa5e9MyuZCBbQ6lbG62qb106s+mUKaeKo799X4qzXvQ=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1eAiGr-0000aB-Nc; Fri, 03 Nov 2017 20:08:53 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1eAiGq-0002fZ-5v; Fri, 03 Nov 2017 20:08:52 +0000 From: Mark Brown To: Baolin Wang Cc: linux-kernel@vger.kernel.org, Mark Brown Subject: [PATCH 2/2] regmap: Clean up hwspinlock on regmap exit Date: Fri, 3 Nov 2017 20:08:51 +0000 Message-Id: <20171103200851.10215-2-broonie@kernel.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171103200851.10215-1-broonie@kernel.org> References: <20171103200851.10215-1-broonie@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should free any hwspinlocks when we destroy the regmap, do so. Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.15.0 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 5ff549fa880b..bfe2f250d011 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1305,6 +1305,8 @@ void regmap_exit(struct regmap *map) kfree(async->work_buf); kfree(async); } + if (IS_ENABLED(REGMAP_HWSPINLOCK) && map->hwlock) + hwspin_lock_free(map->hwlock); kfree(map); } EXPORT_SYMBOL_GPL(regmap_exit);