aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLokesh Vutla2020-12-14 19:39:16 -0600
committerVignesh Raghavendra2020-12-15 08:38:43 -0600
commit617e14d53b8276583672e7ad476c84ab22ea65a0 (patch)
treee64ff0368b9a9c5fd2566a62b0e1ec021e37c94e
parent530c281e5530df69d4cd4b794a571e0535ecdf88 (diff)
downloadkernel-617e14d53b8276583672e7ad476c84ab22ea65a0.tar.gz
kernel-617e14d53b8276583672e7ad476c84ab22ea65a0.tar.xz
kernel-617e14d53b8276583672e7ad476c84ab22ea65a0.zip
net: ethernet: ti: icss_iep: Add checks for NULL pointer
Check for iep validity before accessing iep structure. Since these are exported functions, there is a possibility for passing a dummy pointer. Fixes: 8c2782d9cf85 ("net: ethernet: ti: icss-iep: Make icss-iep a separate driver") Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
-rw-r--r--drivers/net/ethernet/ti/icss_iep.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/net/ethernet/ti/icss_iep.c b/drivers/net/ethernet/ti/icss_iep.c
index d37b62160032..d9116969022e 100644
--- a/drivers/net/ethernet/ti/icss_iep.c
+++ b/drivers/net/ethernet/ti/icss_iep.c
@@ -139,7 +139,7 @@ int icss_iep_get_count_hi(struct icss_iep *iep)
139{ 139{
140 u32 val = 0; 140 u32 val = 0;
141 141
142 if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT) 142 if (iep && (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT))
143 regmap_read(iep->map, ICSS_IEP_COUNT_REG1, &val); 143 regmap_read(iep->map, ICSS_IEP_COUNT_REG1, &val);
144 144
145 return val; 145 return val;
@@ -154,9 +154,10 @@ EXPORT_SYMBOL_GPL(icss_iep_get_count_hi);
154 */ 154 */
155int icss_iep_get_count_low(struct icss_iep *iep) 155int icss_iep_get_count_low(struct icss_iep *iep)
156{ 156{
157 u32 val; 157 u32 val = 0;
158 158
159 regmap_read(iep->map, ICSS_IEP_COUNT_REG0, &val); 159 if (iep)
160 regmap_read(iep->map, ICSS_IEP_COUNT_REG0, &val);
160 161
161 return val; 162 return val;
162} 163}
@@ -170,7 +171,10 @@ EXPORT_SYMBOL_GPL(icss_iep_get_count_low);
170 */ 171 */
171struct ptp_clock *icss_iep_get_ptp_clock(struct icss_iep *iep) 172struct ptp_clock *icss_iep_get_ptp_clock(struct icss_iep *iep)
172{ 173{
173 return iep->ptp_clock; 174 if (iep)
175 return iep->ptp_clock;
176 else
177 return NULL;
174} 178}
175EXPORT_SYMBOL_GPL(icss_iep_get_ptp_clock); 179EXPORT_SYMBOL_GPL(icss_iep_get_ptp_clock);
176 180