From patchwork Wed Nov 8 14:04:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 10048815 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 2EA9C60247 for ; Wed, 8 Nov 2017 16:33:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2757B2A749 for ; Wed, 8 Nov 2017 16:33:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C0D02A74D; Wed, 8 Nov 2017 16:33:54 +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 31AF52A752 for ; Wed, 8 Nov 2017 16:33:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751963AbdKHQdt (ORCPT ); Wed, 8 Nov 2017 11:33:49 -0500 Received: from 19.mo3.mail-out.ovh.net ([178.32.98.231]:42639 "EHLO 19.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752729AbdKHQds (ORCPT ); Wed, 8 Nov 2017 11:33:48 -0500 X-Greylist: delayed 7798 seconds by postgrey-1.27 at vger.kernel.org; Wed, 08 Nov 2017 11:33:47 EST Received: from player771.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id EF7F816E05B for ; Wed, 8 Nov 2017 15:04:54 +0100 (CET) Received: from etezian.org (unknown [211.196.237.107]) (Authenticated sender: andi@etezian.org) by player771.ha.ovh.net (Postfix) with ESMTPSA id 53AED840083; Wed, 8 Nov 2017 15:04:47 +0100 (CET) From: Andi Shyti To: Dmitry Torokhov Cc: Michael Hennerich , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v2 3/3] Input: ad7897 - use separate error handling for different allocators Date: Wed, 8 Nov 2017 16:04:03 +0200 Message-Id: <20171108140403.727-4-andi@etezian.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171108140403.727-1-andi@etezian.org> References: <20171108140403.727-1-andi@etezian.org> X-Ovh-Tracer-Id: 1082552761704825498 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrheelgdeitdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Split the error between devm_kzalloc and devm_input_allocate_device, there is no need to call the second allocator if the first has failed. Besides this doesn't provide practical advantages. CC: Michael Hennerich Signed-off-by: Andi Shyti --- drivers/input/touchscreen/ad7877.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/input/touchscreen/ad7877.c b/drivers/input/touchscreen/ad7877.c index cf59e569d890..98deffde3fe2 100644 --- a/drivers/input/touchscreen/ad7877.c +++ b/drivers/input/touchscreen/ad7877.c @@ -710,6 +710,9 @@ static int ad7877_probe(struct spi_device *spi) } ts = devm_kzalloc(&spi->dev, sizeof(struct ad7877), GFP_KERNEL); + if (!ts) + return -ENOMEM; + input_dev = devm_input_allocate_device(&spi->dev); if (!input_dev) return -ENOMEM;