Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751578AbbEFXOG (ORCPT ); Wed, 6 May 2015 19:14:06 -0400 Received: from mail.ispras.ru ([83.149.199.45]:50031 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751334AbbEFXOA (ORCPT ); Wed, 6 May 2015 19:14:00 -0400 Message-ID: <554AA035.3060407@ispras.ru> Date: Thu, 07 May 2015 02:13:57 +0300 From: Alexey Khoroshilov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Fabio Estevam CC: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio@vger.kernel.org, linux-kernel , ldv-project@linuxtesting.org Subject: Re: [PATCH] iio: hid-sensors: Fix memory leak on failure path in hid_prox_probe() References: <1430948924-4756-1-git-send-email-khoroshilov@ispras.ru> <554A923F.2040205@ispras.ru> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1082 Lines: 38 On 07.05.2015 01:32, Fabio Estevam wrote: > On Wed, May 6, 2015 at 7:14 PM, Alexey Khoroshilov > wrote: > >> Not exactly. Other calls are after >> indio_dev->channels = channels; >> So, >> error_free_dev_mem: >> kfree(indio_dev->channels); >> works for them well. > > indio_dev is allocated using devm_ , so you don't need to free it. > > Your patch is not correct because you only kfree(channels) in the > prox_parse_report() error case, but you missed the other subsequent > functions. > No! The other subsequent functions are AFTER (prox_parse_report() error case is the only BEFORE) indio_dev->channels = channels; and all consequent error cases comes to error_free_dev_mem, where error_free_dev_mem: kfree(indio_dev->channels); that is equivalent to kfree(channels); -- Alexey -- 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/