diff options
author | Achal Verma <achalv@nvidia.com> | 2020-03-16 12:34:55 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2020-03-19 01:00:11 -0400 |
commit | 7b209c53778ed9f6ad912f1669c12ef371085a29 (patch) | |
tree | e8d76c3267ac7493e7c258c8027b797200192b69 | |
parent | 0fd3d620459456212c83673d858d1839e30f2d94 (diff) |
i2c-ivc: fix memory leak.
allocate object when condion for
its use meet.
This fix coverity issue: 2877309
Bug 2028892
Change-Id: Ib87bc5f9192bd8f7428fff43384e2465da4434d2
Signed-off-by: Achal Verma <achalv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2313490
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dmitry Pervushin <dpervushin@nvidia.com>
Reviewed-by: Phoenix Jung <pjung@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r-- | drivers/i2c/busses/i2c-ivc-multi.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/i2c/busses/i2c-ivc-multi.c b/drivers/i2c/busses/i2c-ivc-multi.c index 6239f6b7a..1722abfea 100644 --- a/drivers/i2c/busses/i2c-ivc-multi.c +++ b/drivers/i2c/busses/i2c-ivc-multi.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2017 NVIDIA Corporation. All rights reserved. | 2 | * Copyright (C) 2017-2020 NVIDIA Corporation. All rights reserved. |
3 | * | 3 | * |
4 | * This software is licensed under the terms of the GNU General Public | 4 | * This software is licensed under the terms of the GNU General Public |
5 | * License version 2, as published by the Free Software Foundation, and | 5 | * License version 2, as published by the Free Software Foundation, and |
@@ -106,11 +106,11 @@ struct tegra_i2c_rtcpu_sensor *tegra_i2c_rtcpu_register_sensor( | |||
106 | struct device_node *np_mux, *np_i2c; | 106 | struct device_node *np_mux, *np_i2c; |
107 | struct tegra_i2c_ivc_multi_dev *i2c_ivc_dev; | 107 | struct tegra_i2c_ivc_multi_dev *i2c_ivc_dev; |
108 | 108 | ||
109 | sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); | 109 | if (config->reg_bytes <= 0 || config->reg_bytes > 2) |
110 | if (sensor == NULL) | ||
111 | return NULL; | 110 | return NULL; |
112 | 111 | ||
113 | if (config->reg_bytes <= 0 || config->reg_bytes > 2) | 112 | sensor = kzalloc(sizeof(*sensor), GFP_KERNEL); |
113 | if (sensor == NULL) | ||
114 | return NULL; | 114 | return NULL; |
115 | 115 | ||
116 | sensor->config = *config; | 116 | sensor->config = *config; |