From patchwork Sat Nov 11 05:02:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 10054165 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 0FAC760365 for ; Sat, 11 Nov 2017 05:03:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3142B1B2 for ; Sat, 11 Nov 2017 05:03:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E9942B46D; Sat, 11 Nov 2017 05:03:11 +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 659EE2B1B2 for ; Sat, 11 Nov 2017 05:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750713AbdKKFDF (ORCPT ); Sat, 11 Nov 2017 00:03:05 -0500 Received: from 20.mo3.mail-out.ovh.net ([178.33.47.94]:40642 "EHLO 20.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbdKKFDE (ORCPT ); Sat, 11 Nov 2017 00:03:04 -0500 X-Greylist: delayed 134959 seconds by postgrey-1.27 at vger.kernel.org; Sat, 11 Nov 2017 00:03:04 EST Received: from player771.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 4093216F9A3 for ; Sat, 11 Nov 2017 06:03:03 +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 394F4840087; Sat, 11 Nov 2017 06:02:56 +0100 (CET) From: Andi Shyti To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 2/2] Input: ili210x - use separate error handling for different allocators Date: Sat, 11 Nov 2017 07:02:31 +0200 Message-Id: <20171111050231.29047-3-andi@etezian.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171111050231.29047-1-andi@etezian.org> References: <20171111050231.29047-1-andi@etezian.org> X-Ovh-Tracer-Id: 9549601537745273498 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieeggdekfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd 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. Signed-off-by: Andi Shyti --- drivers/input/touchscreen/ili210x.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c index da868b1d0e83..9344c4436430 100644 --- a/drivers/input/touchscreen/ili210x.c +++ b/drivers/input/touchscreen/ili210x.c @@ -225,8 +225,11 @@ static int ili210x_i2c_probe(struct i2c_client *client, ymax = panel.finger_max.y_low | (panel.finger_max.y_high << 8); priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + input = devm_input_allocate_device(&client->dev); - if (!priv || !input) + if (!input) return -ENOMEM; priv->client = client;