[bug report] firmware: arm_ffa: Add schedule receiver callback mechanism
Dan Carpenter
dan.carpenter at linaro.org
Mon Oct 30 07:31:04 PDT 2023
Hello Sudeep Holla,
The patch 0184450b8b1e: "firmware: arm_ffa: Add schedule receiver
callback mechanism" from Oct 5, 2023 (linux-next), leads to the
following Smatch static checker warning:
drivers/firmware/arm_ffa/driver.c:1251 ffa_partitions_cleanup()
warn: double check that we're allocating correct size: 8 vs 88
drivers/firmware/arm_ffa/driver.c
1243 static void ffa_partitions_cleanup(void)
1244 {
1245 struct ffa_dev_part_info **info;
1246 int idx, count = drv_info->partition_count;
1247
1248 if (!count)
1249 return;
1250
--> 1251 info = kcalloc(count, sizeof(**info), GFP_KERNEL);
I *think* this should be sizeof(*info). It ends up being a smaller
allocation (8 bytes instead of 88).
1252 if (!info)
1253 return;
1254
1255 xa_extract(&drv_info->partition_info, (void **)info, 0, VM_ID_MASK,
We copy count pointers to info. We don't copy entire structs. It still
works but it's larger than necessary.
1256 count, XA_PRESENT);
1257
1258 for (idx = 0; idx < count; idx++)
1259 kfree(info[idx]);
1260 kfree(info);
1261
1262 drv_info->partition_count = 0;
1263 xa_destroy(&drv_info->partition_info);
1264 }
regards,
dan carpenter
More information about the linux-arm-kernel
mailing list