From patchwork Sun Jun 26 13:48:48 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: 9199513 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 4E6EA60752 for ; Sun, 26 Jun 2016 13:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40CDE28540 for ; Sun, 26 Jun 2016 13:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F2D2854B; Sun, 26 Jun 2016 13:48:56 +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 D03A928540 for ; Sun, 26 Jun 2016 13:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752024AbcFZNsz (ORCPT ); Sun, 26 Jun 2016 09:48:55 -0400 Received: from mout.web.de ([212.227.17.12]:51206 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751975AbcFZNsy (ORCPT ); Sun, 26 Jun 2016 09:48:54 -0400 Received: from [192.168.1.2] ([77.182.59.103]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0Lu4uA-1bO8wB1ksY-011UPU; Sun, 26 Jun 2016 15:48:49 +0200 Subject: [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_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: <2fec6004-8191-c117-94c3-86524cfb4780@users.sourceforge.net> Date: Sun, 26 Jun 2016 15:48:48 +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:uonjqLZt1iuDkxf/08P7qXo9rYLnDI0Vi/UO3QZo665EzbKQRhg 1M9PFKBD/JUM55cnEYQ5Avpjp3mjw0XsE4gCXTbO2ODDGFmRkEj/7YiPbpvykfocOH6Bs/k g1McnWCT/BA6XUk0g76eheKwzPgQReJHa0AJvyrSWE0XUfsUWfbeitmWHhR7nttRkoXThQP 9A+dTDZWwjh9iJYshU70g== X-UI-Out-Filterresults: notjunk:1; V01:K0:CjteXCJYVAg=:Y0PjEKuE9vGP73LJ6O5PL3 OUrdPy+39HyfzUmyRunXBpdDnj9wqdyvdf9CnMjdConVMh+3vo9Zs7pgW0XbDcvzhzRyUlY2H 6OKS8BKysJkHnEKI38Ob9Wsm8bW/VGg/UPfZLLTOSI2pmRILP7fGmYrbmLHSwjc3niq2NkQHO j3EpTGe2Acehb4HkUFidO0bODmN/0O/fukaIOg7XCBbszr8GFPHK/v06+JHsBUDWyoxW7gwye VAlxPWrxgJ/SchdW4tibiMb1yHZRzH7r6sqEhi6/OAn7BN7hi5J8L/SM4rr0fkFjXJ8k/QMM0 J/fvK5eTDW33nugw1tFOmn8/3HPhnrPAf2DgnF1K60DhpqfaaoCrJ0EHwRMbPbN8v29pJs0cH dAhL7H9NBgTLenvp+sYS2TQASKiyVQnZ83wl11PR8h9xKOsbGAYdPnGeSJvRKaWTHHGHOOtWX Krp4bVd1hf8ERhk+ORAmHtrqxqtB3KiH3tqllnnNW69k8CUR5qEYqvgRWvzIxEHHdA/hZL4hA 7Veo3rpZFy98cFzDTYGqQMMN5ILV2Y4ZTjCQr9zzhvcnnsIrUT/MusPQ2iDoIFFRq7Ogivtvb hLrHfbJxu2n/eG+uO0xX62fQFfO9XDrzUNaA4RKKD4aVIxTrS2oTUsfx3GEPxm0YdaVKMrB1U ggNre/ecwNKqfREoWBdmV9bnFypFJbCyhiXQ+XA36mgP+v7uhB/h9iKVrfIHlrSRXFB+WAfHV R1WrlJLwZzGo1WVcNPNzSsWQDD2Nyq5xpK5zfpkWU2KXlyu0p1+x09Lma3J1Ha8hI75s6GK4R 1FbSICS 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 13:40:35 +0200 The platform_device_put() function was called in one case by the add_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/dm355evm_msp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c index 14661ec..270e19c 100644 --- a/drivers/mfd/dm355evm_msp.c +++ b/drivers/mfd/dm355evm_msp.c @@ -199,11 +199,8 @@ static struct device *add_child(struct i2c_client *client, const char *name, int status; pdev = platform_device_alloc(name, -1); - if (!pdev) { - dev_dbg(&client->dev, "can't alloc dev\n"); - status = -ENOMEM; - goto err; - } + if (!pdev) + return ERR_PTR(-ENOMEM); device_init_wakeup(&pdev->dev, can_wakeup); pdev->dev.parent = &client->dev;