From patchwork Fri Mar 12 17:03:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 399557 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 0E212C433E9 for ; Fri, 12 Mar 2021 17:04:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D931C65027 for ; Fri, 12 Mar 2021 17:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232238AbhCLRDg (ORCPT ); Fri, 12 Mar 2021 12:03:36 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:47487 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbhCLRDT (ORCPT ); Fri, 12 Mar 2021 12:03:19 -0500 Received: from mail-wr1-f70.google.com ([209.85.221.70]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lKlC2-0007hS-Pc for stable@vger.kernel.org; Fri, 12 Mar 2021 17:03:18 +0000 Received: by mail-wr1-f70.google.com with SMTP id m9so11442433wrx.6 for ; Fri, 12 Mar 2021 09:03:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=q9Si3P9xn1fyl7+Pl1eKHeH3/uCSKLYl0ZR8qsuF1A0=; b=dOFCDJaeMgejlOXE/LU596/uCGx96+nAcmMxrGoEwFDHzhF1+bdnXuGTrUOPHvYvvi XZdljHFrQ7qjNWRr+guSX4t6j15OM+C47WzZ/Vv6FxRmjsf8crRoGiaONmyOx+GeetDO uVtBB4qBLElFX1DsTpadDu8cd05rdWhr6eZSUchmCbXGTminCFxc5HjCDS4AAjNvp5WN I79YJfOnOxai3Nk0XuW4b0cuiu8jWpyBBBCJbaLZaOoIMtLhAQbhiwu4N9mKNH2Qxtyg EYabwr/CwX+tDX1qXxvTa3bEfsLFv6gNW8scbhpRyV/u/4zHp/YJ5vd1N0Npq+moXxak lJnQ== X-Gm-Message-State: AOAM531v2y0nf+InK7gGahRVz2dXaboo80jw/ChExivHZ3rxkNqbHX/L mwoi+BI2iKikQpA/GblA0JioM2Czv+fWzCYTP9wxJxSreP/sT2m0uv0r4vs5oyk+HvU/tulgfk8 MYUgYRyceX5pNo7fxdYrYv2nShRun0nKheQ== X-Received: by 2002:adf:e70a:: with SMTP id c10mr14767170wrm.85.1615568598243; Fri, 12 Mar 2021 09:03:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLEqxDF5QPw2Y48bItkMG+3mYbKHOjVdG5uwMClJmH/vSwQUtbMUIGgIYsVNDDIN1rSPlPJw== X-Received: by 2002:adf:e70a:: with SMTP id c10mr14767153wrm.85.1615568598124; Fri, 12 Mar 2021 09:03:18 -0800 (PST) Received: from localhost.localdomain (adsl-84-226-167-205.adslplus.ch. [84.226.167.205]) by smtp.gmail.com with ESMTPSA id w11sm9401803wrv.88.2021.03.12.09.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 09:03:17 -0800 (PST) From: Krzysztof Kozlowski To: stable@vger.kernel.org Cc: Navid Emamdoost , Alexandru Ardelean , Jonathan Cameron , Krzysztof Kozlowski Subject: [PATCH stable v4.4] iio: imu: adis16400: fix memory leak Date: Fri, 12 Mar 2021 18:03:11 +0100 Message-Id: <20210312170311.17464-1-krzysztof.kozlowski@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Navid Emamdoost commit 9c0530e898f384c5d279bfcebd8bb17af1105873 upstream. In adis_update_scan_mode_burst, if adis->buffer allocation fails release the adis->xfer. Signed-off-by: Navid Emamdoost Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron (cherry picked from commit 9c0530e898f384c5d279bfcebd8bb17af1105873) [krzk: backport applied to adis16400_buffer.c instead of adis_buffer.c] Signed-off-by: Krzysztof Kozlowski --- drivers/iio/imu/adis16400_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c index 90c24a23c679..c0eb9dfd1c45 100644 --- a/drivers/iio/imu/adis16400_buffer.c +++ b/drivers/iio/imu/adis16400_buffer.c @@ -37,8 +37,11 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev, return -ENOMEM; adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL); - if (!adis->buffer) + if (!adis->buffer) { + kfree(adis->xfer); + adis->xfer = NULL; return -ENOMEM; + } tx = adis->buffer + burst_length; tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);