From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752747AbdKHPXw (ORCPT ); Wed, 8 Nov 2017 10:23:52 -0500 Received: from 16.mo3.mail-out.ovh.net ([188.165.56.217]:58058 "EHLO 16.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752717AbdKHPXr (ORCPT ); Wed, 8 Nov 2017 10:23:47 -0500 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-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. 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; -- 2.15.0