Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3654851rwb; Sat, 12 Nov 2022 09:49:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf7DZqZBowyXVNAl03pPWQiULZKKRceFCzc4K/qudgAUFRgprVs2pLdvWiHN+U40lLw+PqW/ X-Received: by 2002:a50:fe88:0:b0:467:9f6b:d80 with SMTP id d8-20020a50fe88000000b004679f6b0d80mr1553232edt.18.1668275358697; Sat, 12 Nov 2022 09:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668275358; cv=none; d=google.com; s=arc-20160816; b=Ft2ib9z0yKeHuqkRSqZFpGL2WlV0WquBdz/Hb1uG4QeMco1pAzo3xV0YQJuCiqCeKN sat1W43nDhgNZs9v94zkXqnn0l6pwH5VdP232jFnR+ecfOIYjAMkiZdcVjl55pbTTiTi 4SRMcC9uiJE0RjDkqqaWkpUP7Usfk8M3IvDvFQ5ufClwyhUazymYQgPSfVLOX69lc72O +6+6wKb5zSdJbLKbpjUFeZknx46CHCNUTVKDDCu2y43b3tr7lY5GVcnbMQ/+cLit5bPt NLo9LjNKvO7EjNXGfyXgiADscKp/HEi5l30ga/1x2RyJszIGhe5h4zs/UbHIbENCogWz ly4g== 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:subject:cc:to:from:date :dkim-signature; bh=3MJ8IPLoslxi+a5nEmCz5pCefJbHnGYOLGNRmAxms8w=; b=A/yX83LlWtWmVVFpoOW5k4g7OUvnzNVwYeWyUD8Hii4KvmBSPxkfyC0ruDuQfnXmtM JW07/Mvdj2AoB+UiE1awRRAdAYwBRrANmKixih5W6VnzmhC0mtsFDgHtUCnrhWRWROlj IhMFdDt44r2o4u6N/gMUwjytCEe4eKCKcF0AO5h57NT0rJ7GgDRK/4unqFGFVdbFF9Ei 6cKuM+jD3kTLQZzxMwbeA46hSDDC4U8u9avS8IkvLYsLcwlVGc/DjTDegeBgWuXYb3fH ZVLKYigSUNcc3TrR1Ck94IS8SK1XVQiyIIdkB5I6BiP8zdl91c56sxPTI+e5oY2HoRqh MixQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ox0U/r7v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h21-20020a170906111500b0078b88453306si3681989eja.285.2022.11.12.09.48.56; Sat, 12 Nov 2022 09:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ox0U/r7v"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234905AbiKLRhr (ORCPT + 91 others); Sat, 12 Nov 2022 12:37:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbiKLRhp (ORCPT ); Sat, 12 Nov 2022 12:37:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C292DBBF; Sat, 12 Nov 2022 09:37:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id 71CBDB80989; Sat, 12 Nov 2022 17:37:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75CC8C433C1; Sat, 12 Nov 2022 17:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668274660; bh=qFlagUlNT8sMkPJSQL0Q9To0a6qPqsLDFfKwQFSbbxY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ox0U/r7vY0S3/KbbCfr/6X8PjV/w1zIdCcTJRwsQrlKpzsjNtwQJnY3zu6xxGyLKx NrJZbjmDNuBkRORZeR/k3k9zPejWhMH0rpSNDhB3Y34DAMf7y3JbVX8Ptv2A1qSunK 8koFxdav2JjNt5kvlgHQRzTPX7GGtMdYylfg4ZOBhF6nr/5xGYbfoBASXYhLmRJEk1 gp9ne92qqDkgH6LujmadHkoPGge/O/+72U3I64lan4RilcRN+QdHzyksGfyCRPjNaT I3Rt3M3TZ9veg0C/2392Tp246hW34qA+GBsDjEjRU83PasgEYC4MtiOp6F30/yuNK0 7OSaxoadxg6Iw== Date: Sat, 12 Nov 2022 17:49:55 +0000 From: Jonathan Cameron To: Jagath Jog J Cc: Dong Chenchen , dan@dlrobertson.com, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, yuehaibing@huawei.com Subject: Re: [Patch] iio: accel: bma400: Fix memory leak in bma400_get_steps_reg() Message-ID: <20221112174955.2d1d294a@jic23-huawei> In-Reply-To: References: <20221110010726.235601-1-dongchenchen2@huawei.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Fri, 11 Nov 2022 23:12:32 +0530 Jagath Jog J wrote: > On Thu, Nov 10, 2022 at 6:37 AM Dong Chenchen wrote: > > > > When regmap_bulk_read() fails, it does not free steps_raw, > > which will cause a memory leak issue, this patch fixes it. > > > > Fixes: d221de60eee3 ("iio: accel: bma400: Add separate channel for step counter") > > Signed-off-by: Dong Chenchen > > Reviewed-by: Jagath Jog J > > Thanks for catching this Applied to the fixes-togreg branch of iio.git and marked for stable. Thanks, Jonathan > > Regards, > Jagath > > > --- > > drivers/iio/accel/bma400_core.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c > > index ad8fce3e08cd..43976cf5a91b 100644 > > --- a/drivers/iio/accel/bma400_core.c > > +++ b/drivers/iio/accel/bma400_core.c > > @@ -805,8 +805,10 @@ static int bma400_get_steps_reg(struct bma400_data *data, int *val) > > > > ret = regmap_bulk_read(data->regmap, BMA400_STEP_CNT0_REG, > > steps_raw, BMA400_STEP_RAW_LEN); > > - if (ret) > > + if (ret) { > > + kfree(steps_raw); > > return ret; > > + } > > *val = get_unaligned_le24(steps_raw); > > kfree(steps_raw); > > return IIO_VAL_INT; > > -- > > 2.25.1 > >