Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4491342ybx; Mon, 4 Nov 2019 14:18:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxL93yHAYSsQwJcnTjdF5K2o+wj5u5Kf4aH4FEI60ybiKXS5i5PbQlvwmbdVQ3LPgQPx9PW X-Received: by 2002:a50:fc0a:: with SMTP id i10mr31811049edr.94.1572905891372; Mon, 04 Nov 2019 14:18:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905891; cv=none; d=google.com; s=arc-20160816; b=MtbcrFv6knAtBV0sUhatDbxwZTMlpCnk2L5pqfW8J5ba2hsl0n6ISUARiC9WbWENeU revx9Utd0VFXIVktS4CfDGztiOgg07FetUsaiinzP8dIdUi713rMYnrC6XDVhF3RGUhl WgJPE0tMBCHGFtZrccdt93XvRpXA17eLH+jgWciJI1sONx6CHXzFPrISCmuJ1VS9l00F LU0FZ3qG5d/6QSRoxKmxjYfq4NrJKo1DCpn3fno3ivAdeUGTIddr9TkC+D4eGjVpp00a RZqPALl5DbbNblVFWrYcbvz/9NqApAFDxxURHjqCU7ISjCqZnMTY9WADGgT4LjmqMmKj E07w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WUwMH9r0vXgjbFCSfe8wc9meE/pDymvcYrkgUkyChgQ=; b=xJLw2DDH+kLLEbS5395u8fRtQI+EzBuxc//7ptfWGdZd7QwPoZIqwryQZN5OMJTLRm kmsUQvFfsFLYo+UmTx2sN4zHySH5XiqnKI6UhbgO9vt5d25PQxjPOVkkytBgkk4AGEa+ P8W33D2Nrc12fQ2r8JG2YN4Ty07yTQWEOS4YbpyWNV7+BwsKS5womb2HwOjysJS3C5zt RwKQfEcu3x8J4ofdb2Dt9/wfjqlWwT063MqjDh423akV+XnNi7DkrNk+4Y0KAmd68c+W bWHVsygoABBzsMOP33dhomp4ldJ/HSD/qqP9czkXbHiMsFr0889XfagP2P5iSSbc+NBH sKfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tZH4nXtC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si9835411edi.179.2019.11.04.14.17.39; Mon, 04 Nov 2019 14:18:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tZH4nXtC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390083AbfKDWHJ (ORCPT + 99 others); Mon, 4 Nov 2019 17:07:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:39358 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390067AbfKDWHD (ORCPT ); Mon, 4 Nov 2019 17:07:03 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 94A88214D8; Mon, 4 Nov 2019 22:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905223; bh=uEND3GKoWK+g/JWo/oyDeh6QDH6dGdOrvIJh9bfh8S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tZH4nXtCE+dFEUjGeBo5rTGBsSt6Qw6xkjegAIMvLI6MJ2t4Cu70mOcZHJF/PnpWg FLK8jnp9wF70Dt+/2rYfu1RaNilSgaPYRQE+YtYJisATRbvw9SoON1P5x1hsL476sr 2PYXSbcm9Nerc6sj90X8Te11xvjAcgeUyydEK4XU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Alexandru Ardelean , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.3 071/163] iio: imu: adis16400: release allocated memory on failure Date: Mon, 4 Nov 2019 22:44:21 +0100 Message-Id: <20191104212145.044132462@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit ab612b1daf415b62c58e130cb3d0f30b255a14d0 ] In adis_update_scan_mode, if allocation for adis->buffer fails, previously allocated adis->xfer needs to be released. Signed-off-by: Navid Emamdoost Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/imu/adis_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 9ac8356d9a954..f446ff4978091 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -78,8 +78,11 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, return -ENOMEM; adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL); - if (!adis->buffer) + if (!adis->buffer) { + kfree(adis->xfer); + adis->xfer = NULL; return -ENOMEM; + } rx = adis->buffer; tx = rx + scan_count; -- 2.20.1