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