From patchwork Wed Jan 10 18:41:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 186984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp982663dyi; Wed, 10 Jan 2024 10:42:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IET+Ktp7OibChUbTc5TgvEb08rUCc+9qPgnkyHKSg+5pNPQ0OmxMTm5u7tAmjFFb9jFndf7 X-Received: by 2002:a17:907:9216:b0:a28:aef6:9965 with SMTP id ka22-20020a170907921600b00a28aef69965mr782926ejb.94.1704912126387; Wed, 10 Jan 2024 10:42:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704912126; cv=none; d=google.com; s=arc-20160816; b=GdkSLG8cm29ek82B9f8LmUc7Qji8x0veJzvmgBF8EwsLSwJITmvugKGYe7aR/uvA9G VqelCXBnWU/2kQ3UIFOaZHuJL32VAtM1hwfY/c5tQaGKgRd4x9k1e1Rt5aRyDGRlAwpr QzH3SbqpfkjQSOvhUYh49BnyfkEDx/pqMUMETYB4BxY3Bn7oCjFYDheRN23HXsf9rDsv //+NTh7fyKZeTtoOH9H9VD+mhoQuTnqBBv5bvJbyrRDLpA72d/4f2CY2GWPUkmnVzZ1F c3i4FgEHM0uOxSew6RX9Xr3son34iv1AsJ+0bnZYcrnK+4QizZrWIA0afrCV7fRSFGhf 2zpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=WFUXY3mgVSfGBpcTG7FlJdmYxdRI+GVT2C0gkL18kmE=; fh=kA98k4u316AaJYeRjC7jKvE8VI47jXMmR9qwvQsXkzI=; b=YQcOsg+xhPT39XOEab9FQKUquxDvtWmCBzqhe3MtmsMK5f3T2NKdSyIvgO79yyS7Ji zUwAeVgsFHl6PjS72igO2YMqZbNpx7oZ21hNApNjWRUS/JcVRl47w779caBdPi14ScxD SNobaOlMFZoZ/zu2V5fJMop+V99sXNR7awoV75OT2CWQrH0wTLqQCXNSkIhmnreHRt9S a+JASHigWJNH90DZ1BWWa9hUEjDtQi71cHN/2U4rXTiZWUVePhB7TNgg0BsttXKboBwP GNKrUlmcBEB7M/ye2w6b7S7/gWkymBOQmqZoUTxhPyP8L5CAw605EFuiVQ9/WZn2Itmw zTfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lbg0e0H+; spf=pass (google.com: domain of linux-kernel+bounces-22608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bk20-20020a170906b0d400b00a2b082e0b66si1914904ejb.957.2024.01.10.10.42.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 10:42:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lbg0e0H+; spf=pass (google.com: domain of linux-kernel+bounces-22608-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EFCF31F2441A for ; Wed, 10 Jan 2024 18:42:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFEF74D5AA; Wed, 10 Jan 2024 18:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Lbg0e0H+" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 854004D584 for ; Wed, 10 Jan 2024 18:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40e4d64a431so23338335e9.0 for ; Wed, 10 Jan 2024 10:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704912105; x=1705516905; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=WFUXY3mgVSfGBpcTG7FlJdmYxdRI+GVT2C0gkL18kmE=; b=Lbg0e0H+66RpqrsFiKSo8IfUkt0HeFysdZOmKfsLpRsDBVQjDS8ikN4DMoL7x8BYyn 896rKuUEOPUbzdZHpYrcxyittsIAKz/1pLoDpDdzXyRSDPsKaob/z6Z1nWaW4lHufCuL exJ4x8e1xqzyRl8cmUaonkN2M9VD2b2xKMAL20HmazCWsuRT9Izaf0tjUuORbSABVxWb 7UvYm/yup+dpuoI+/dIz2U8yWKb3Ckt92rtQfw0LuAgd44iJgoPi3g5ylA6J1JyDDc7O LGWae/FHySSziCpVEu7Q4cDTJ+85s1CVTivHTM+D54wbeUcOiszKATwjhobd0CwZv6K1 yzQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704912105; x=1705516905; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WFUXY3mgVSfGBpcTG7FlJdmYxdRI+GVT2C0gkL18kmE=; b=S2+yQWfoyul+HafiTlCzGy46eva0XOIp5DW+J4/d8IJRzg5Y2DKYY1JDdmtuIWWv08 r/k62d+RG2Wowp3KW2ENbtZg3Xp0J/BrXsf0u5J8GUXBChXJDWDbBwQAzapLGZZFU8m0 qbsfr/VgLgAMWw0w99o9uf4IlNPpOVJ3gi2qVDSNkZsC2nLLJ2h/knI+9Vtn6Rsk4LJ0 8UgbFS18Srs8bWX7FKDidf4EpM+cUMox2tW4C1kIl28WKhnFAPAH04fO8Y6aOo9ALctL qxFiBB4k5kMj2JqWx0pq6djGVd7C1daYzdrICG3EY6kGCM7HMsEnyaINfa+jGKlPBiEv rhIA== X-Gm-Message-State: AOJu0YyQSrEE28Mn4g74DLX/jrM3C+BWPKeOhaaCjvgsxVKGUC1Clm2d jZg2CjYHFmxttZYO3dO25ozNXct1Y30luReiHAdZX4eEfzU= X-Received: by 2002:a05:600c:4452:b0:40e:40fc:6d43 with SMTP id v18-20020a05600c445200b0040e40fc6d43mr957913wmn.98.1704912104738; Wed, 10 Jan 2024 10:41:44 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id g14-20020a05600c4ece00b0040d5f3ef2a2sm3029695wmq.16.2024.01.10.10.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 10:41:44 -0800 (PST) Date: Wed, 10 Jan 2024 21:41:41 +0300 From: Dan Carpenter To: Claudiu Beznea Cc: Geert Uytterhoeven , Linus Walleij , linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] pinctrl: renesas: rzg2l: Fix double unlock in rzg2l_dt_subnode_to_map() Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787729937800894152 X-GMAIL-MSGID: 1787729937800894152 If rzg2l_map_add_config() fails then the error handling calls mutex_unlock(&pctrl->mutex) but we're not holding that mutex. Move the unlocks to before the gotos to avoid this situation. Fixes: d3aaa7203a17 ("pinctrl: renesas: rzg2l: Add pin configuration support for pinmux groups") Signed-off-by: Dan Carpenter --- (Not tested). drivers/pinctrl/renesas/pinctrl-rzg2l.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 80fb5011c7bb..8bbfb0530538 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -453,7 +453,8 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, gsel = pinctrl_generic_add_group(pctldev, name, pins, num_pinmux, NULL); if (gsel < 0) { ret = gsel; - goto unlock; + mutex_unlock(&pctrl->mutex); + goto done; } /* @@ -464,6 +465,7 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, fsel = pinmux_generic_add_function(pctldev, name, pin_fn, 1, psel_val); if (fsel < 0) { ret = fsel; + mutex_unlock(&pctrl->mutex); goto remove_group; } @@ -490,8 +492,6 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, remove_group: pinctrl_generic_remove_group(pctldev, gsel); -unlock: - mutex_unlock(&pctrl->mutex); done: *index = idx; kfree(configs);