staging: iio: adc: ad7280a: check for devm_kasprint() failure
authorNicholas Mc Guire <hofrat@osadl.org>
Tue, 27 Nov 2018 17:05:04 +0000 (18:05 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 1 Dec 2018 16:35:14 +0000 (16:35 +0000)
commit53e8785c248df097364b75e550d06bbc58db8af8
tree01d87f2449a246cd885f65a934ef75e940a75c74
parent88884a503ba854f3c0ff0fef458ac00aefa62671
staging: iio: adc: ad7280a: check for devm_kasprint() failure

devm_kasprintf() may return NULL on failure of internal allocation thus
the assignments to  attr.name  are not safe if not checked. On error
ad7280_attr_init() returns a negative return so -ENOMEM should be
OK here (passed on as return value of the probe function). To make the
error case more readable a temporary  iio_attr  is introduced and the code
refactored.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: 2051f25d2a26 ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System2")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/adc/ad7280a.c