From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1695BC61DA4 for ; Thu, 16 Feb 2023 14:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbjBPOm1 (ORCPT ); Thu, 16 Feb 2023 09:42:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230201AbjBPOm0 (ORCPT ); Thu, 16 Feb 2023 09:42:26 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66165311C3; Thu, 16 Feb 2023 06:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676558545; x=1708094545; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=5bVsjkDJKcW49tiFh1Ukt7n2ye4PhDRhCc+U/ksoYtI=; b=d9LuPDKhPFqx5PY+u513CitQKeEtceahP41j1jLfmA0REPp2uQVDTwEc NOOsWQ4r58vRHZvTTxe7XpLvqONVux6XuY77AMbsjPY/f3mpdGIY1MJBZ TMAJWyC+6nbDLSfSQOyIsPUhDWbq9nSdPDO2QKudtVBqcLjcJJtCSn0NN G6oMoKp2Ujt5nN9Oelrn08xZHHOn4Oca2Emjyn1EnrCzx7U5NbOncPPoX JeHru6IrUts0MeiTmHxJlRqDAnLSspzGWsTqyG6TozIHisASknVZTtT3G GNI65RxP1Mry+hY34qmkI2wLk1cEdH5L06QMrDI9s2zESfMUXErvOEGw0 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10623"; a="359161965" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="359161965" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 06:42:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10623"; a="844165526" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="844165526" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 16 Feb 2023 06:42:22 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pSfSm-007p7Z-2f; Thu, 16 Feb 2023 16:42:20 +0200 Date: Thu, 16 Feb 2023 16:42:20 +0200 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Kent Gibson , Linus Walleij , Viresh Kumar , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Mirsad Goran Todorovac Subject: Re: [PATCH] gpio: sim: fix a memory leak Message-ID: References: <20230216141555.116219-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230216141555.116219-1-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Thu, Feb 16, 2023 at 03:15:55PM +0100, Bartosz Golaszewski wrote: > Fix an inverted logic bug in gpio_sim_remove_hogs() that leads to GPIO > hog structures never being freed. Ha-ha, I stared to this code, and in the head I was "okay, this loop is until chip_label is *not* NULL, so should be fine". At the same time, "! is hard to process", see for example 2754435d4c82 ("ACPI / battery: get rid of negations in conditions") which I had suggested. Reviewed-by: Andy Shevchenko P.S. But my patch I mentioned looks also good to have, no? > Fixes: cb8c474e79be ("gpio: sim: new testing module") > Reported-by: Mirsad Goran Todorovac > Signed-off-by: Bartosz Golaszewski > --- > drivers/gpio/gpio-sim.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c > index 60514bc5454f..9e3893b19e4f 100644 > --- a/drivers/gpio/gpio-sim.c > +++ b/drivers/gpio/gpio-sim.c > @@ -736,7 +736,7 @@ static void gpio_sim_remove_hogs(struct gpio_sim_device *dev) > > gpiod_remove_hogs(dev->hogs); > > - for (hog = dev->hogs; !hog->chip_label; hog++) { > + for (hog = dev->hogs; hog->chip_label; hog++) { > kfree(hog->chip_label); > kfree(hog->line_name); > } > -- > 2.37.2 > -- With Best Regards, Andy Shevchenko