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: