gpiolib: cdev: fix null pointer dereference in linereq_free()
authorKent Gibson <warthog618@gmail.com>
Wed, 6 Jul 2022 08:45:07 +0000 (16:45 +0800)
committerBartosz Golaszewski <brgl@bgdev.pl>
Thu, 7 Jul 2022 10:18:18 +0000 (12:18 +0200)
commitc8e27a4a5136e7230f9e4ffcf132705bf56864cc
tree76b9c9125ccfb8459b96efd4e84951ac978adc9e
parent8af3a0b23818af59971f538bf258c15e1033ea55
gpiolib: cdev: fix null pointer dereference in linereq_free()

Fix a kernel NULL pointer dereference reported by gpio kselftests.

linereq_free() can be called as part of the cleanup of a failed request,
at which time the desc for a line may not have been determined, so it
is unsafe to dereference without a check.

Add a check prior to dereferencing the line desc.

Fixes: 2068339a6c35 ("gpiolib: cdev: Add hardware timestamp clock type")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
drivers/gpio/gpiolib-cdev.c