Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2811646rdh; Wed, 27 Sep 2023 13:31:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErpdHQ4LT76MsS1UedlQ8TJkVVGUJfZe3/jocKD2Uueyo1IYZqVFWGGT6VdqLUkTuHG4r1 X-Received: by 2002:a17:903:183:b0:1c6:21b4:30bb with SMTP id z3-20020a170903018300b001c621b430bbmr3331414plg.15.1695846684334; Wed, 27 Sep 2023 13:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695846684; cv=none; d=google.com; s=arc-20160816; b=IotCDXHIVdD1/E/wAPpB7Y9ihynfHvSQekx1jax0m6/gRPJ1Q/GZhvkaZ0rKvl5Oky SQRUEPLMxxotpKRc6jFa5mQrdjhNnEoCb6R6nFJ6i8VkGesfVs/47NceL6nu6HjHAtG9 Lxkx7IQV+7cyCbEHzr/xvrCBGC1Y1FTHRCUDgacO/T33rgmt69yXHqa5wMWdIxgYgadU ewrfT1k8BYecgodAXq4eyqUc9eY1XqvsK2BqpnpH8j3KaZZVoEncd38KvHYtvusACtU9 8Lu8fNUocynTY/dtMQlOwvOevSJtTjFqEYcHSyx6GVQoZAKDQdSzLfTXVunI9tJQVkBM B9SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hS9XRL4UjV0H2cpjxdGbKe5r7XpEbOe3UCWMjzVSxnQ=; fh=nz7VNHiZPehN5kI1Zu9EriA/WIR1rcAjRtHa5jFbAAo=; b=WJ5dodaieIktPvOnSeo2BvPgLezrDihz77NmuyR23Y37dbQoe7MkR0RG63CnZauuv5 V+vOMVEPwmu7TvuSKmow5XbRBrYgCfPQhA3KZ4uTEuhXEJZTouw2BIK4sqM28fuynA+N J3zIax30NAZ9S02uUfYRzlwFK7EZKg4UBR2R346zbVjaKCst5iAEYF/y3pyEOP4Om8dh hIGclTwXkNeXC9DKAainObTJXc1pjVq/ujDCT8+Qj3DkPvUXhe5F5E/C7GWg4TEtWc/S ZaTBOJXlXO+UD4+R9E947Fux56itM4/yzRsZ7incQ4BwWTSeA2Hvzl+wtKyH+w0jpWZ/ H/Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=CaNAj+cC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id le6-20020a170902fb0600b001c62b659f98si6225005plb.79.2023.09.27.13.31.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:31:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=CaNAj+cC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BF37583352B5; Wed, 27 Sep 2023 13:27:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjI0U0Y (ORCPT + 99 others); Wed, 27 Sep 2023 16:26:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbjI0U0W (ORCPT ); Wed, 27 Sep 2023 16:26:22 -0400 Received: from sonic301-22.consmr.mail.ir2.yahoo.com (sonic301-22.consmr.mail.ir2.yahoo.com [77.238.176.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9A29136 for ; Wed, 27 Sep 2023 13:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1695846378; bh=hS9XRL4UjV0H2cpjxdGbKe5r7XpEbOe3UCWMjzVSxnQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=CaNAj+cCuGb6YyJQlBRadGA9ofythS8P1VjyawDuhrmlK2WHuqE0kGl/NE50+lR6j1SW7IlDdUj0cvLgOCVi5MtT9mjG/MJGIDR1Yfyk1MEb5K3lmwF08yx6THd4O3vfIXYnlGqqj2NBP8wv6WhjE1UEpHcGlq0EfEgvF/e3HMt/CFyjtEoCndmjASButUyC2yDudRBhsUC++4f9amR19Vm2XmCCcsl8MUFbaG5rhOZvZdBq61MX9aFawsSwwlNml4s0ozwg6TQzCPwGJG3e9255W5KdPrNOAzPXK9dNMyUYgfHwv+GIl7A19wRUSgVfodRqSILDoo2tvBI0vTkpeQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1695846378; bh=t/vll2PBhzBw/8NYoeZg9NA6vDIZhTGXTDI9AT675Mi=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=fTyshhS1q/k6oIcAZhXqs804VMSQSfQyxU+AY74cKsl++uy71VrMXrhgaq6zD+pWJuJMBsS9iF97oXo9hRaoeeBLjlP2Y30i3KZGc/j0XXps0RmNXHB9O5MYjPLw7xxOKUexDuvMoRIN4AQnJz7gdPFvJa42jsjYhzXf3AhBHCYfwOLafsZgO03Pi+9io6/0IeE9iDDDVvij2na5WZc2rlbgvJn3Dxnym+2ZlrVe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VVjAoo XqOmpBuN9eHLhe2T0MT.190F_OFw2xkKiEDGJM0pS9K4UJBhl_d33cTx9N.qSTT44od12mY_j9k7 eUn7clBafHMGXgjVk9z8a3ARI5hQluBI_VkM67bsGK9CpX2tYPP1_qm.YMPHIxS2cwhSNQHX4s7V 0zjJ6NexmEKS7j92kID9N2QdqxzE_qgA2G_9WHd3gLOj1GA8ae.wZSJwxuRqJzEysr9zOlCIwS89 CeiXtAkRoxQJoJlW7UytSdCuI1G.S9dLgMc8XUzzuSCJfLyJnQHJuu4YhnqzfyFNMboYA9mnnR3Z tCuESas4vpouU2OHQoERySZRC0riMd_E- X-Sonic-MF: X-Sonic-ID: b130448e-4358-44c0-b48a-0e54654458f6 Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Wed, 27 Sep 2023 20:26:18 +0000 Received: by hermes--production-ir2-55db9d9d5-5hvhf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 1d998f486e26fd309cd8d11c694d3a2b; Wed, 27 Sep 2023 20:26:17 +0000 (UTC) From: Jakob Hauser To: Sebastian Reichel Cc: Lee Jones , Stephen Rothwell , Yang Yingliang , Christophe Jaillet , Stephan Gerhold , Raymond Hackley , Henrik Grimler , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH 3/5] power: supply: rt5033_charger: fix missing unlock Date: Wed, 27 Sep 2023 22:26:00 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 13:27:15 -0700 (PDT) From: Yang Yingliang Fix missing mutex_unlock() in some error path. Fixes: 12cc585f36b8 ("power: supply: rt5033_charger: Add cable detection and USB OTG supply") Signed-off-by: Yang Yingliang Signed-off-by: Jakob Hauser --- drivers/power/supply/rt5033_charger.c | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/power/supply/rt5033_charger.c b/drivers/power/supply/rt5033_charger.c index 2c2073b8979d..091ca4a21f29 100644 --- a/drivers/power/supply/rt5033_charger.c +++ b/drivers/power/supply/rt5033_charger.c @@ -361,7 +361,8 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger) 0x37 << RT5033_CHGCTRL2_CV_SHIFT); if (ret) { dev_err(charger->dev, "Failed set OTG boost v_out\n"); - return -EINVAL; + ret = -EINVAL; + goto out_unlock; } /* Set operation mode to OTG */ @@ -369,7 +370,8 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger) RT5033_CHGCTRL1_MODE_MASK, RT5033_BOOST_MODE); if (ret) { dev_err(charger->dev, "Failed to update OTG mode.\n"); - return -EINVAL; + ret = -EINVAL; + goto out_unlock; } /* In case someone switched from charging to OTG directly */ @@ -378,9 +380,10 @@ static int rt5033_charger_set_otg(struct rt5033_charger *charger) charger->otg = true; +out_unlock: mutex_unlock(&charger->lock); - return 0; + return ret; } static int rt5033_charger_unset_otg(struct rt5033_charger *charger) @@ -420,8 +423,10 @@ static int rt5033_charger_set_charging(struct rt5033_charger *charger) /* In case someone switched from OTG to charging directly */ if (charger->otg) { ret = rt5033_charger_unset_otg(charger); - if (ret) + if (ret) { + mutex_unlock(&charger->lock); return -EINVAL; + } } charger->online = true; @@ -448,6 +453,7 @@ static int rt5033_charger_set_mivr(struct rt5033_charger *charger) RT5033_CHGCTRL4_MIVR_MASK, RT5033_CHARGER_MIVR_4600MV); if (ret) { dev_err(charger->dev, "Failed to set MIVR level.\n"); + mutex_unlock(&charger->lock); return -EINVAL; } @@ -463,7 +469,7 @@ static int rt5033_charger_set_mivr(struct rt5033_charger *charger) static int rt5033_charger_set_disconnect(struct rt5033_charger *charger) { - int ret; + int ret = 0; mutex_lock(&charger->lock); @@ -475,7 +481,8 @@ static int rt5033_charger_set_disconnect(struct rt5033_charger *charger) RT5033_CHARGER_MIVR_DISABLE); if (ret) { dev_err(charger->dev, "Failed to disable MIVR.\n"); - return -EINVAL; + ret = -EINVAL; + goto out_unlock; } charger->mivr_enabled = false; @@ -483,16 +490,19 @@ static int rt5033_charger_set_disconnect(struct rt5033_charger *charger) if (charger->otg) { ret = rt5033_charger_unset_otg(charger); - if (ret) - return -EINVAL; + if (ret) { + ret = -EINVAL; + goto out_unlock; + } } if (charger->online) charger->online = false; +out_unlock: mutex_unlock(&charger->lock); - return 0; + return ret; } static enum power_supply_property rt5033_charger_props[] = { -- 2.39.2