Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbdIVFUp (ORCPT ); Fri, 22 Sep 2017 01:20:45 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37414 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbdIVFUo (ORCPT ); Fri, 22 Sep 2017 01:20:44 -0400 X-Google-Smtp-Source: AOwi7QD1RxAK3uY/WrYAAzt2bEJZ2jHOfSXxzFDcbt+XDZ60Erypvw6gXPqqNBZNiNMuI6BZDybH0A== From: Arvind Yadav To: rmfrfs@gmail.com, johan@kernel.org, elder@kernel.org, gregkh@linuxfoundation.org Cc: greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: greybus: light: Release memory obtained by kasprintf Date: Fri, 22 Sep 2017 10:49:43 +0530 Message-Id: <33458cb8d9a1b20752517fe7c6ada21c13069fc6.1506056972.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1267 Lines: 41 - Free memory region, if gb_lights_channel_config is not successful. - No need to add check for gb_lights_channel_flash_config(). Signed-off-by: Arvind Yadav --- changes in v2: - Subject line changed. - add kfree in __gb_lights_led_unregister(). - No need to check return value of gb_lights_channel_flash_config(). drivers/staging/greybus/light.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c index 3f4148c..bc1f8d2 100644 --- a/drivers/staging/greybus/light.c +++ b/drivers/staging/greybus/light.c @@ -926,6 +926,8 @@ static void __gb_lights_led_unregister(struct gb_channel *channel) led_classdev_unregister(cdev); channel->led = NULL; + kfree(cdev->name); + cdev->name = NULL; } static void gb_lights_channel_unregister(struct gb_channel *channel) @@ -998,11 +1000,8 @@ static int gb_lights_channel_config(struct gb_light *light, light->has_flash = true; - ret = gb_lights_channel_flash_config(channel); - if (ret < 0) - return ret; + return gb_lights_channel_flash_config(channel); - return ret; } static int gb_lights_light_config(struct gb_lights *glights, u8 id) -- 1.9.1