From patchwork Tue Oct 27 13:51:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 312900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E07E3C388F9 for ; Tue, 27 Oct 2020 14:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9233B22264 for ; Tue, 27 Oct 2020 14:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809392; bh=E2lVoZPmw/mZoa8vzVe9Oe1Sn3u000mDTbCd64MEIR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iAogYQpcIumPTrNdYcupQyo20vm+7rcqpYFhKCmGc1gfkuNyZqyeS+YjdWUaC3aWC RxJUd2fkKVjiO1+qENeOVf1PjWEGcPz87PKGQ0JnN1O4MAx4FKvvt4g3aV/mJwrqRG LcBCuW0Y5LDtRWy1k9XTh1yXFX6pPwEgoUCTAoqk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760799AbgJ0Ogb (ORCPT ); Tue, 27 Oct 2020 10:36:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:35390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760792AbgJ0Oga (ORCPT ); Tue, 27 Oct 2020 10:36:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB67C22202; Tue, 27 Oct 2020 14:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809389; bh=E2lVoZPmw/mZoa8vzVe9Oe1Sn3u000mDTbCd64MEIR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQZaGdfiXRLkciwoGt9jI/pE6daZW/eq1eCWULW+gBufG0x8QpcFZ2I1Zl6hDXahI EaolOokpQQbjFbY/MKpzOYSeYNpBwub/Fyli8dBFUAKYvdsvshi5tUUs3G3wnzU6tN Jz00C/wjc6OBCsVXpTEEC2HJafeF2BAmhG9yWXJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Lee Jones , Sasha Levin Subject: [PATCH 5.4 177/408] mfd: sm501: Fix leaks in probe() Date: Tue, 27 Oct 2020 14:51:55 +0100 Message-Id: <20201027135503.308033744@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit 8ce24f8967df2836b4557a23e74dc4bb098249f1 ] This code should clean up if sm501_init_dev() fails. Fixes: b6d6454fdb66 ("[PATCH] mfd: SM501 core driver") Signed-off-by: Dan Carpenter Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/sm501.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c index 154270f8d8d78..bbcde58e2a11e 100644 --- a/drivers/mfd/sm501.c +++ b/drivers/mfd/sm501.c @@ -1424,8 +1424,14 @@ static int sm501_plat_probe(struct platform_device *dev) goto err_claim; } - return sm501_init_dev(sm); + ret = sm501_init_dev(sm); + if (ret) + goto err_unmap; + + return 0; + err_unmap: + iounmap(sm->regs); err_claim: release_resource(sm->regs_claim); kfree(sm->regs_claim);