From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdKKFIe (ORCPT ); Sat, 11 Nov 2017 00:08:34 -0500 Received: from 9.mo3.mail-out.ovh.net ([87.98.184.141]:56130 "EHLO 9.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750813AbdKKFIc (ORCPT ); Sat, 11 Nov 2017 00:08:32 -0500 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.15.0