mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: arch/arm64/kernel/acpi.c:443 acpi_ffh_address_space_arch_setup() warn: possible memory leak of 'ffh_ctxt'
Date: Wed, 22 Feb 2023 16:56:07 +0300	[thread overview]
Message-ID: <202302191417.dAl9NuE8-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   925cf0457d7e62ce08878ffb789189ac08ca8677
commit: 45494d77f279d0420f06376dcf105b23e300c5a4 Merge branches 'acpi-scan', 'acpi-bus', 'acpi-tables' and 'acpi-sysfs'
config: arm64-randconfig-m031-20230219 (https://download.01.org/0day-ci/archive/20230219/202302191417.dAl9NuE8-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202302191417.dAl9NuE8-lkp@intel.com/

New smatch warnings:
arch/arm64/kernel/acpi.c:443 acpi_ffh_address_space_arch_setup() warn: possible memory leak of 'ffh_ctxt'

Old smatch warnings:
arch/arm64/kernel/acpi.c:448 acpi_ffh_address_space_arch_setup() warn: possible memory leak of 'ffh_ctxt'

vim +/ffh_ctxt +443 arch/arm64/kernel/acpi.c

1d280ce099db39 Sudeep Holla 2022-11-10  433  int acpi_ffh_address_space_arch_setup(void *handler_ctxt, void **region_ctxt)
1d280ce099db39 Sudeep Holla 2022-11-10  434  {
1d280ce099db39 Sudeep Holla 2022-11-10  435  	enum arm_smccc_conduit conduit;
1d280ce099db39 Sudeep Holla 2022-11-10  436  	struct acpi_ffh_data *ffh_ctxt;
1d280ce099db39 Sudeep Holla 2022-11-10  437  
1d280ce099db39 Sudeep Holla 2022-11-10  438  	ffh_ctxt = kzalloc(sizeof(*ffh_ctxt), GFP_KERNEL);
1d280ce099db39 Sudeep Holla 2022-11-10  439  	if (!ffh_ctxt)
1d280ce099db39 Sudeep Holla 2022-11-10  440  		return -ENOMEM;
1d280ce099db39 Sudeep Holla 2022-11-10  441  
1d280ce099db39 Sudeep Holla 2022-11-10  442  	if (arm_smccc_get_version() < ARM_SMCCC_VERSION_1_2)
1d280ce099db39 Sudeep Holla 2022-11-10 @443  		return -EOPNOTSUPP;

Do these checks before the ffh_ctxt = kzalloc()?

1d280ce099db39 Sudeep Holla 2022-11-10  444  
1d280ce099db39 Sudeep Holla 2022-11-10  445  	conduit = arm_smccc_1_1_get_conduit();
1d280ce099db39 Sudeep Holla 2022-11-10  446  	if (conduit == SMCCC_CONDUIT_NONE) {
1d280ce099db39 Sudeep Holla 2022-11-10  447  		pr_err("%s: invalid SMCCC conduit\n", __func__);
1d280ce099db39 Sudeep Holla 2022-11-10  448  		return -EOPNOTSUPP;

Same

1d280ce099db39 Sudeep Holla 2022-11-10  449  	}
1d280ce099db39 Sudeep Holla 2022-11-10  450  
1d280ce099db39 Sudeep Holla 2022-11-10  451  	if (conduit == SMCCC_CONDUIT_SMC) {
1d280ce099db39 Sudeep Holla 2022-11-10  452  		ffh_ctxt->invoke_ffh_fn = __arm_smccc_smc;
1d280ce099db39 Sudeep Holla 2022-11-10  453  		ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_smc;
1d280ce099db39 Sudeep Holla 2022-11-10  454  	} else {
1d280ce099db39 Sudeep Holla 2022-11-10  455  		ffh_ctxt->invoke_ffh_fn = __arm_smccc_hvc;
1d280ce099db39 Sudeep Holla 2022-11-10  456  		ffh_ctxt->invoke_ffh64_fn = arm_smccc_1_2_hvc;
1d280ce099db39 Sudeep Holla 2022-11-10  457  	}
1d280ce099db39 Sudeep Holla 2022-11-10  458  
1d280ce099db39 Sudeep Holla 2022-11-10  459  	memcpy(ffh_ctxt, handler_ctxt, sizeof(ffh_ctxt->info));
1d280ce099db39 Sudeep Holla 2022-11-10  460  
1d280ce099db39 Sudeep Holla 2022-11-10  461  	*region_ctxt = ffh_ctxt;
1d280ce099db39 Sudeep Holla 2022-11-10  462  	return AE_OK;
1d280ce099db39 Sudeep Holla 2022-11-10  463  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


                 reply	other threads:[~2023-02-22 13:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202302191417.dAl9NuE8-lkp@intel.com \
    --to=error27@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®