diff mbox series

[V1,1/1] Input: atmel_mxt_ts: Don't try to free unallocated kernel memory

Message ID 1545994214-30023-2-git-send-email-sanjeev_chugh@mentor.com (mailing list archive)
State Accepted
Headers show
Series atmel_mxt_ts: Avoid memory free operation for unallocated kernel memory pointer | expand

Commit Message

Chugh, Sanjeev Dec. 28, 2018, 10:50 a.m. UTC
If the user attempts to update Atmel device with an invalid configuration
cfg file, error handling code is trying to free cfg file memory which is
not allocated yet hence results into kernel crash.

This patch fixes the order of memory free operations.

Signed-off-by: Sanjeev Chugh <sanjeev_chugh@mentor.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dmitry Torokhov Dec. 29, 2018, 1:06 a.m. UTC | #1
On Fri, Dec 28, 2018 at 04:20:14PM +0530, Sanjeev Chugh wrote:
> If the user attempts to update Atmel device with an invalid configuration
> cfg file, error handling code is trying to free cfg file memory which is
> not allocated yet hence results into kernel crash.
> 
> This patch fixes the order of memory free operations.
> 
> Signed-off-by: Sanjeev Chugh <sanjeev_chugh@mentor.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 1f27587..7eb8eff 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -1938,10 +1938,10 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw)
>  	/* T7 config may have changed */
>  	mxt_init_t7_power_cfg(data);
>  
> -release_raw:
> -	kfree(cfg.raw);
>  release_mem:
>  	kfree(cfg.mem);
> +release_raw:
> +	kfree(cfg.raw);
>  	return ret;
>  }
>  
> -- 
> 2.7.4
>
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 1f27587..7eb8eff 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1938,10 +1938,10 @@  static int mxt_update_cfg(struct mxt_data *data, const struct firmware *fw)
 	/* T7 config may have changed */
 	mxt_init_t7_power_cfg(data);
 
-release_raw:
-	kfree(cfg.raw);
 release_mem:
 	kfree(cfg.mem);
+release_raw:
+	kfree(cfg.raw);
 	return ret;
 }