Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4490882ybx; Mon, 4 Nov 2019 14:17:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzZMwl2EEjM48Wnk7NB43d2jhMr/KtT73di3BRgg2MI41eHAABpMeXU+9SRjdsqxQ+QODeJ X-Received: by 2002:a50:b685:: with SMTP id d5mr32431724ede.276.1572905866602; Mon, 04 Nov 2019 14:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905866; cv=none; d=google.com; s=arc-20160816; b=gHA3Oa/YH3mmKQ88CWSl2APlAw1tNA76g0FCL9ejmShel+yXh9D52U8SPhJ/kAv5CA Q6Idb0Mr3tXa5zuk6m8pXPHjXSkOtkY4KcZyZMNrEsccp0f6FGxS8y2G16B0OKERLzKc 4xIL52YNImLmDc9xXtjR9PZPV6svz8wvMhspYNWHeztQ8pQJ9juXu6nlR0MrwcgQxwjP zvx2yWTN4KkRcU6tYY9zH4uje2jByRyg3f9exHQWR0AoikQqVWWHNGwNhWeSXp/3Ka6G y8kA4NtWbmusGntEOsew5AmvmgZH2k45izAzfdoTAMe7m80WVSql/caPNM26taMbN02h cErg== 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=zfW2+mYD0WqS7YQU3W7vqhzJUCilf9EC/VFHO7AUiMI=; b=1AcZpQSSjcLqf38Qv8T/6QqQkvKoACZUeFgtPg95GqKR3bJHplCG3FmpanRPMJIF3s QTxz9hJVFRTjLXe775HRFElYObuhk9woUF7IlzhjE6d2GfIXfuZkLgpjHrLOOIdVuSMi CW/mGk5uIy/jrcpXzR3ZKv0krCr38xdtv7Clp5ZRqISbC2Qzf7lgsoJXTCeZl9lekwcy wkavIBhmCam3nfAO0xq10xWnKl84L8816GliwqydOvh/8VscU8qhF868PThfR+T/IqZI rAecxnUeBbkpKPvDQKrMvt5dtV5LhT9JupkZQSGS7gdsXgvpHLMhB/jrkDtl9sO6ok8y T7tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FnGHS6ba; 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 u8si8491777edb.57.2019.11.04.14.17.20; Mon, 04 Nov 2019 14:17:46 -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=FnGHS6ba; 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 S2389611AbfKDWHL (ORCPT + 99 others); Mon, 4 Nov 2019 17:07:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:39452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390074AbfKDWHH (ORCPT ); Mon, 4 Nov 2019 17:07:07 -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 A9E21214D8; Mon, 4 Nov 2019 22:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905226; bh=ygm/bLbEKE+ydYb6n27zhUbjztKPi1bevmfl1GTnNCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnGHS6baAJ/ctLIwjCrPRVuQjHBHc4JcQGbGYuLcCJaHh5Y6q+yxRHOzP+tBLKTYp 2aPgFeabzapzRYir//Rd0FVwsyERaXq/S6o0vklCRl8euv7HQPAIUi6mSN9DSgFz/M VbnS0qYogBRPhg8BNdVUyMjkpRmWuPmGz3lrVyLg= 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 072/163] iio: imu: adis16400: fix memory leak Date: Mon, 4 Nov 2019 22:44:22 +0100 Message-Id: <20191104212145.097944480@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 9c0530e898f384c5d279bfcebd8bb17af1105873 ] 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 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 f446ff4978091..4998a89d083d5 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c @@ -35,8 +35,11 @@ static int adis_update_scan_mode_burst(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(adis->burst->reg_cmd); -- 2.20.1