From patchwork Mon May 16 06:26:11 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: 9098451 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 803DABF440 for ; Mon, 16 May 2016 06:26:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7F1620218 for ; Mon, 16 May 2016 06:26:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBA7E20260 for ; Mon, 16 May 2016 06:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751013AbcEPG0d (ORCPT ); Mon, 16 May 2016 02:26:33 -0400 Received: from mout.web.de ([212.227.15.14]:56837 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbcEPG0c (ORCPT ); Mon, 16 May 2016 02:26:32 -0400 Received: from [192.168.1.2] ([78.48.32.23]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0MOj5C-1azSxL44D0-00636N; Mon, 16 May 2016 08:26:26 +0200 Subject: [PATCH 1/2] 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> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <3c168185-ec2d-f1f7-fe70-8a230b884ed2@users.sourceforge.net> Date: Mon, 16 May 2016 08:26:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <05b7db2a-437a-60ac-d289-71d2150e7f5f@users.sourceforge.net> X-Provags-ID: V03:K0:7qIgl857NTTJQKaeRg7O65E9+K1y86mm2WWSjpmSs+i4jLqfvuo D1Tie6XPpoTh3zT2hzIVgdVUM07QEwf+fvR18gtLeaSHHHSOcHnEkept85g12jVAyUUNJnB XjHm4iln7D6e37M4njr4vYBXk2iDj/d4eimysE9cC5GJ+bO5WiyeGQO3Gi04xczz6AbUvV0 85uM/wjTu0PGfswY5TJiA== X-UI-Out-Filterresults: notjunk:1; V01:K0:I+ZAhgj9eUQ=:kVUcat11X+WFsG08P4ARis ExnnbD3X2lR6rEMA/Dlirvv2Nx/ci7cCNp43FEqM2hkqKJaXQFt/jkntjvox5b4wpwFeMREBl NZuRgbIHJWL97K8wqAxkaBNC/MzbQjJdfz3dc/7AideVFKMkaNmlwBGSdupRLXf+E45GoAfpy SId6aXAt9g66cxATmUtMMs92le/wJHECbeZKUL9qpDlYO+PANVWP+b4OjsOIDWgKWt6aTG4ZS pKVIxVpC2+eLhymyfhAm9bk2HUOSZxjIUp6/ZWlJUGAEHfI5LIIC4nbytY1R82wR5fUal/Lob 8HgoGt/fL7M8IPnYrZNmqJQIpOAD13+XI+R3OZy+FVpgD7VXIyb+ikwwkgdaU1hdMv7vFsV7W CWM1fje7tFnZI5zQKbGBYyL3emYbI3IoYa/Skgejme+THYBIuNwxPsKgLMttmHat+S926TDzT 5B0GjAsw6NdE9IuAU6fLKEZEssaZkSwhszSXy3xb30+tZ3jFRWqOQ0iQmablE6nJtuuUL3QLz PqoxH0FyDYYfPmz4baaZungeC1KrzmGxuPgjgJ07kECOA4ukmf8/HTEFNadb4PmJez7uMRWrn OPQc/NEuiEwmjcb2dr8zTCRZb3aIUcNJHAoK3w/ZzxaXyhegDVFzuwH7vEZda5NyT/jUK2lL/ tgcyav8podkaJeWTyY5h+0LMiR4dpOARHI0WKXowjhYpGsiRNAG+EdWelgh6KJSzE72ImfgYS 70wp1G3wgjrqXyzu4IjS27nZCqtv6c8mewL0LJu8ut73MD4v4CJC7AqLQ0AWGnGOKMqQLaqGb AgcIsEkxqKLynBD7kvt2Ing7aTiQg== Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 15 May 2016 19:20:28 +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. * Change an error message. * 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, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 831696e..dc34e69 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -623,9 +623,10 @@ add_numbered_child(unsigned mod_no, const char *name, int num, pdev = platform_device_alloc(name, num); if (!pdev) { - dev_dbg(&twl->client->dev, "can't alloc dev\n"); - status = -ENOMEM; - goto err; + dev_err(&twl->client->dev, + "Allocation failed for device: %s\n", + name); + return ERR_PTR(-ENOMEM); } pdev->dev.parent = &twl->client->dev;