Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3117941pxm; Mon, 28 Feb 2022 12:23:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrMCQvrqjPx3KJoR/hDonhDhuv06h1FBwY0zzgTjksX66N7xQ/T0czhZ9cKUb9ZxARunND X-Received: by 2002:a17:90a:d481:b0:1bc:7850:6403 with SMTP id s1-20020a17090ad48100b001bc78506403mr18308013pju.63.1646079833798; Mon, 28 Feb 2022 12:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079833; cv=none; d=google.com; s=arc-20160816; b=ps6/GGtQJMBxZtZ9vyT1N9UY3iiL/5+WKSI3H5BOWK33QY6IHRt3HmfhFaQVuEjFjj rOSDcJdptnkyoayHSqY1EmLT5gJbtaPf9/f546fRqwfAhyZi8RLk8II/6deJFxZ2tZwK ueeRa1McABgqd3xWUj/wzggrx9JF5qdMZTDoA0vzyCB4sygp3XKy20AzZgUFe7R1rN8T V1NMBobExnvSVVWqrXekc8Ej+ZfavZGtdQy0IbS4aesCDGgOvv9wLN66Tq7xhUO/9JXK rE94C/xNYl/yJsLzAPZe6ZIJ2FrNibe8L1dCMwaVMRoV3dK7JgBjgxqD/bGszidFngc5 XQNQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6CjaksXbc/fA8mOGHm6gFoVbu4aUeugrfDeaByJEqUM=; b=TUoc1/wnDBTCIG8reZtsvhyu0HWVlaOxwtWmgefAZx8Ds0fev6r7lKxzW2zAihL+h5 e2jR7GTaOhryaCsbGRB+4hY5EtO3eyEtPCI+ySm/Rqi8po6Lb9ugdfJCDldUMQOgJ7/5 8wo3WYJd2jG9EX3T7P+etPV705UeDj7XIzq7Nop37lw8XJGEB1BE0HnYaBCZCvvoBXIR UN+SeallfJUgv6oVH0qzl4SflEX3UYE4RcPr0T4pKxNhfZ8Ry07Zvd6p4VBUB7jEUp4R lJxgdQc/lb5ZDcyucUvHnbHuNLViz8eeolg40L1UMFRNyXMDDwa15T5lI43AZ34LBnxl lN5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pLdgsf1X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q16-20020a170902dad000b0015011e142f5si12570967plx.55.2022.02.28.12.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:23:53 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pLdgsf1X; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4A1D61C60C3; Mon, 28 Feb 2022 11:42:47 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238449AbiB1RmE (ORCPT + 99 others); Mon, 28 Feb 2022 12:42:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238305AbiB1Rh0 (ORCPT ); Mon, 28 Feb 2022 12:37:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D2801FA78; Mon, 28 Feb 2022 09:32:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 30E70609EE; Mon, 28 Feb 2022 17:32:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 471E4C340E7; Mon, 28 Feb 2022 17:32:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069544; bh=m3D1UtU+qGhEenIw23BRw2gMcv27uFHzZlSA1vb5nuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLdgsf1X9hXOopK6lNVWvaWqAckKn+JLF4jOkEcPfMVICvdQNwA0dRWaFCc1WDwax IdPFB/3epfN4/tv6XUkkxgLUj+B0lxMsGxZXeaXf/c2o3mKeqfzIcFKNn8arFiJ/Hu 099P0pTclThqJNRcSMiAKA4Psi/NkqGjhXZAg3Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.4 33/53] iio: adc: men_z188_adc: Fix a resource leak in an error handling path Date: Mon, 28 Feb 2022 18:24:31 +0100 Message-Id: <20220228172250.668376063@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172248.232273337@linuxfoundation.org> References: <20220228172248.232273337@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET commit e0a2e37f303828d030a83f33ffe14b36cb88d563 upstream. If iio_device_register() fails, a previous ioremap() is left unbalanced. Update the error handling path and add the missing iounmap() call, as already done in the remove function. Fixes: 74aeac4da66f ("iio: adc: Add MEN 16z188 ADC driver") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/320fc777863880247c2aff4a9d1a54ba69abf080.1643445149.git.christophe.jaillet@wanadoo.fr Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/men_z188_adc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/iio/adc/men_z188_adc.c +++ b/drivers/iio/adc/men_z188_adc.c @@ -103,6 +103,7 @@ static int men_z188_probe(struct mcb_dev struct z188_adc *adc; struct iio_dev *indio_dev; struct resource *mem; + int ret; indio_dev = devm_iio_device_alloc(&dev->dev, sizeof(struct z188_adc)); if (!indio_dev) @@ -129,8 +130,14 @@ static int men_z188_probe(struct mcb_dev adc->mem = mem; mcb_set_drvdata(dev, indio_dev); - return iio_device_register(indio_dev); + ret = iio_device_register(indio_dev); + if (ret) + goto err_unmap; + return 0; + +err_unmap: + iounmap(adc->base); err: mcb_release_mem(mem); return -ENXIO;