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 72B38CD37BC for ; Sat, 16 Sep 2023 11:20:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234080AbjIPLTd (ORCPT ); Sat, 16 Sep 2023 07:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbjIPLT3 (ORCPT ); Sat, 16 Sep 2023 07:19:29 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5707A199; Sat, 16 Sep 2023 04:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694863164; x=1726399164; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=28CXMS/F/59wSEgJdT75kdHNhUkNdqDaK7+0AF2byx8=; b=f+X6/NskvkW9NWFejuan12v/DrjEFypwZ1Ts4f6TJhBUL4Hx3VCeTnL5 /i6xLKwK9FeBxCZkEpkmpSuBQixYaYDKBnvPzS71N00fCd3d3NN9lP5N/ sxI3p3RjPjK7R9yflxfNBFFBAvxha0NM/nPJYEPIeNxQ+OI0T2uujtItY 7gXPoU39mIMilspRa8EP4viauWFqFVnW8RYO6IQvgZYJlrxzM2Y+UbZ9X t0++ni2JFzqd9IJxg2wavlEgmsGdirh6qOrMOPEACqevEs2g2fUpDGSXa DKrUXfMWK1RqGwmmoIoQIc5h/fsNN2lrBaJjM13NU2Jh9O34sGY87eD71 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="445882735" X-IronPort-AV: E=Sophos;i="6.02,152,1688454000"; d="scan'208";a="445882735" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2023 04:19:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10834"; a="748493833" X-IronPort-AV: E=Sophos;i="6.02,152,1688454000"; d="scan'208";a="748493833" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga007.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2023 04:19:21 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qhTKY-0000000GqlV-2ZrN; Sat, 16 Sep 2023 14:19:18 +0300 Date: Sat, 16 Sep 2023 14:19:18 +0300 From: Andy Shevchenko To: Bartosz Golaszewski Cc: Linus Walleij , Kent Gibson , Alexey Dobriyan , Peter Zijlstra , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH 1/2] gpio: sim: fix an invalid __free() usage Message-ID: References: <20230915123423.75948-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230915123423.75948-1-brgl@bgdev.pl> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 15, 2023 at 02:34:22PM +0200, Bartosz Golaszewski wrote: > From: Bartosz Golaszewski > > gpio_sim_make_line_names() returns NULL or ERR_PTR() so we must not use > __free(kfree) on the returned address. Let's rework the function so that > it returns the size of the gpio-line-names array or a negative error > code on failure. This way we know that the string array will either stay > NULL or be set to a correct, kcalloc()'ed address. ... > + names = kcalloc(line_names_size, sizeof(*line_names), GFP_KERNEL); sizeof(*line_names) is a bit unusual here. names is typed as double pointer, while line_names as a tripple one. -- With Best Regards, Andy Shevchenko