counter: fix an IS_ERR() vs NULL bug

There are 8 callers for devm_counter_alloc() and they all check for NULL
instead of error pointers. I think NULL is the better thing to return
for allocation functions so update counter_alloc() and devm_counter_alloc()
to return NULL instead of error pointers.

Fixes: c18e2760308e ("counter: Provide alternative counter registration functions")
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220111173243.GA2192@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Dan Carpenter and committed by Greg Kroah-Hartman fc55e63e a6501e4b

Changed files
+6 -9
drivers
counter
+6 -9
drivers/counter/counter-core.c
··· 90 int err; 91 92 ch = kzalloc(sizeof(*ch) + sizeof_priv, GFP_KERNEL); 93 - if (!ch) { 94 - err = -ENOMEM; 95 - goto err_alloc_ch; 96 - } 97 98 counter = &ch->counter; 99 dev = &counter->dev; ··· 121 err_ida_alloc: 122 123 kfree(ch); 124 - err_alloc_ch: 125 126 - return ERR_PTR(err); 127 } 128 EXPORT_SYMBOL_GPL(counter_alloc); 129 ··· 205 int err; 206 207 counter = counter_alloc(sizeof_priv); 208 - if (IS_ERR(counter)) 209 - return counter; 210 211 err = devm_add_action_or_reset(dev, devm_counter_put, counter); 212 if (err < 0) 213 - return ERR_PTR(err); 214 215 return counter; 216 }
··· 90 int err; 91 92 ch = kzalloc(sizeof(*ch) + sizeof_priv, GFP_KERNEL); 93 + if (!ch) 94 + return NULL; 95 96 counter = &ch->counter; 97 dev = &counter->dev; ··· 123 err_ida_alloc: 124 125 kfree(ch); 126 127 + return NULL; 128 } 129 EXPORT_SYMBOL_GPL(counter_alloc); 130 ··· 208 int err; 209 210 counter = counter_alloc(sizeof_priv); 211 + if (!counter) 212 + return NULL; 213 214 err = devm_add_action_or_reset(dev, devm_counter_put, counter); 215 if (err < 0) 216 + return NULL; 217 218 return counter; 219 }