Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mux: mmio: Fix IS_ERR() vs NULL check in probe()

The devm_kmalloc() function never returns error pointers, it returns
NULL on error. Fix the error checking.

Fixes: 4863cb2b0f50 ("mux: mmio: Add suspend and resume support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Link: https://patch.msgid.link/aSsIP7oKrhKfCUv3@stanley.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dan Carpenter and committed by
Greg Kroah-Hartman
9aeacd2f 0ea4cc93

+4 -4
+4 -4
drivers/mux/mmio.c
··· 101 101 mux_mmio = mux_chip_priv(mux_chip); 102 102 103 103 mux_mmio->fields = devm_kmalloc(dev, num_fields * sizeof(*mux_mmio->fields), GFP_KERNEL); 104 - if (IS_ERR(mux_mmio->fields)) 105 - return PTR_ERR(mux_mmio->fields); 104 + if (!mux_mmio->fields) 105 + return -ENOMEM; 106 106 107 107 mux_mmio->hardware_states = devm_kmalloc(dev, num_fields * 108 108 sizeof(*mux_mmio->hardware_states), GFP_KERNEL); 109 - if (IS_ERR(mux_mmio->hardware_states)) 110 - return PTR_ERR(mux_mmio->hardware_states); 109 + if (!mux_mmio->hardware_states) 110 + return -ENOMEM; 111 111 112 112 for (i = 0; i < num_fields; i++) { 113 113 struct mux_control *mux = &mux_chip->mux[i];