Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751590AbbEFVtC (ORCPT ); Wed, 6 May 2015 17:49:02 -0400 Received: from mail.ispras.ru ([83.149.199.45]:48392 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbbEFVs5 (ORCPT ); Wed, 6 May 2015 17:48:57 -0400 From: Alexey Khoroshilov To: Jonathan Cameron Cc: Alexey Khoroshilov , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe() Date: Thu, 7 May 2015 00:48:44 +0300 Message-Id: <1430948924-4756-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1201 Lines: 34 If prox_parse_report() fails, memory allocated for channels is not deallocated, since it is still in local variable channels while kfree() is called with indio_dev->channels. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/iio/light/hid-sensor-prox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 91ecc46ffeaa..d0d188108a11 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -281,8 +281,9 @@ static int hid_prox_probe(struct platform_device *pdev) ret = prox_parse_report(pdev, hsdev, channels, HID_USAGE_SENSOR_PROX, prox_state); if (ret) { + kfree(channels); dev_err(&pdev->dev, "failed to setup attributes\n"); - goto error_free_dev_mem; + return ret; } indio_dev->channels = channels; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/