From patchwork Sun Jun 26 13:45:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9199503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52C0A60752 for ; Sun, 26 Jun 2016 13:46:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4609028540 for ; Sun, 26 Jun 2016 13:46:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A6242854B; Sun, 26 Jun 2016 13:46:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA71A28540 for ; Sun, 26 Jun 2016 13:46:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752121AbcFZNpx (ORCPT ); Sun, 26 Jun 2016 09:45:53 -0400 Received: from mout.web.de ([212.227.17.11]:60027 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbcFZNpw (ORCPT ); Sun, 26 Jun 2016 09:45:52 -0400 Received: from [192.168.1.2] ([77.182.59.103]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0LmcjH-1bpP8T1JTv-00aFrq; Sun, 26 Jun 2016 15:45:46 +0200 Subject: [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() To: Lee Jones , Tony Lindgren , linux-omap@vger.kernel.org References: <566ABCD9.1060404@users.sourceforge.net> <5682D228.7070902@users.sourceforge.net> <20160111082922.GB14104@x1> <05b7db2a-437a-60ac-d289-71d2150e7f5f@users.sourceforge.net> <20160608111442.GB14888@dell> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: Date: Sun, 26 Jun 2016 15:45:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:fNvRQasPQZ9jwn278LHOPem7St9g+YgEeZc9OU7DXzMTZj7rrkD VuCUV3JDyfXmpNWFdOerJTHoldAZuaS2g12zI4d8SsEfA5xSzi1GBkJzKmTfZgdKsmYOuL0 RsU/GJEimPR4tLXwE6ldvx+PY46qlH51al8n7GSAJxwLlSHPDyO9Epd7e6AKOy2pnjpGnC5 JIGmsNeltGXEyhoq+Ys5A== X-UI-Out-Filterresults: notjunk:1; V01:K0:HJzXBnhm2Kw=:DRdAm4fTOkhjlKkzJqW5zr 1Yu7GljrfjYn/WfsN93YZjMS9v+VQtLMlp0BljOpa4b4u/s4fOH92pngO87ohBngJfH+ljg83 EXePhm3QLaeXIjT8HXxNq8y/z6OS8WAeXxntVAYEXrff70CRiAe+ALCX7fvOh+EqxZlZLzpCk wq830dL4tqB4/YBDJA3scvJyMBkRCn2vg5j3BzFrAI/LM7k3vuee47djTrJzKYGfRTd0htO9I iRTd7Eudfi2gUKyPIwUBLP9KTe4og5MqeI3oXozvpq1LAy2Ol3yJPbULnFH0XOS7P3VvuWlN2 vrHK4FUiYvI0sOt+/l87/MKOqEqDTShQfSeAYT5jBh9suoYzHcbZeXMUi7TQVMNROe8b+byhh 0K/aF9rA5lv2g49qy14Pa6xO0TPq1D83kpFLLldFARVXn0HBTTorGdtyiXWliVr3f1EBX4l2H aJKaLsqIGyuFB33vXRE41TajVkPG0VE7lMQAb9Y/gaJmSLXwPhPzjUv7Xg0xaDvRRwTP1Micp XOcpa2zLv+x9ZtsQ8kdrIroTUGYf8pAUmQb5tg5VLQ//1HA2r+XEV43Q7bS7YgaPlDoShmj2j 0S8/t+QeDrjh7Hx379dlmQ4gZrA6V0vDYSDtbN6MHNcK0FY1Xo8BNQDE0dBAKqIkj4Za4SKDB bs1ZbKiZ+ebu4ja8P3uzrKy6PsbANM6bR396q4eVZulSnsMQT9uwNYbVbp7xpGAz29rzvaz/j 4XKm8u95hETDbelV6LKy7NZqDEvjYls+re/jS8yiqQvsxoIAlaKngpIeqXV5EWEw5lhS9oOSU +nXH/M1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 26 Jun 2016 12:25:36 +0200 The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer. Return directly in this case. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/mfd/twl-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 831696e..9458c6d 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -622,11 +622,8 @@ add_numbered_child(unsigned mod_no, const char *name, int num, twl = &twl_priv->twl_modules[sid]; pdev = platform_device_alloc(name, num); - if (!pdev) { - dev_dbg(&twl->client->dev, "can't alloc dev\n"); - status = -ENOMEM; - goto err; - } + if (!pdev) + return ERR_PTR(-ENOMEM); pdev->dev.parent = &twl->client->dev;