usb: chipidea: usb2: check memory allocation failure
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 25 Aug 2017 05:22:53 +0000 (07:22 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Aug 2017 09:44:39 +0000 (11:44 +0200)
Check memory allocation failure and return -ENOMEM in such a case, as
already done few lines below for another memory allocation.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/ci_hdrc_usb2.c

index d162cc0bb8ceae29edfa1498ef766a8cafaae775..99425db9ba62b20beda2c08c0cd2e49639c87e52 100644 (file)
@@ -52,6 +52,8 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
 
        if (!ci_pdata) {
                ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
+               if (!ci_pdata)
+                       return -ENOMEM;
                *ci_pdata = ci_default_pdata;   /* struct copy */
        }