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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E35F3C4332F for ; Mon, 30 Oct 2023 16:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4hO4g5El1TuPt13iZMthqvyUIAY8vR1i+7aYcAmXyhs=; b=ele++JY4fjZG7x OKXn5di/e4AxgRszzix1PA2OyuKj9X2MUtK61+Q3U2z6Fx2IFhMhtJ0nxqn62lZfDH+Dy5Pgub0oC fx+wtBor8wJmLUXlyiExr9t6XymthvqizXHQcdzhRxodZ0eTPMIEzhgaklpNz1btTlbJ/GFo+Qaq4 zPtuEaO6KcUUHuREeGLObbbeeKI2gT0ROhz9xjr8BVg8XgIjC/kQWsIXKIllpA9nQCqEgwkezKCov Ai/pBgVD4akSM305cVzIBWljXa34PyvweuX7xdVKgJuEAQ4GyJvHgeIQFcGl5E/7x44jwLjmiwQkX rlARcLs1wnD7370wHBoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxUhc-003b6r-0e; Mon, 30 Oct 2023 16:01:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxUhZ-003b64-2E for linux-arm-kernel@lists.infradead.org; Mon, 30 Oct 2023 16:01:19 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96293FEC; Mon, 30 Oct 2023 09:01:52 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 53C353F738; Mon, 30 Oct 2023 09:01:10 -0700 (PDT) Date: Mon, 30 Oct 2023 16:01:07 +0000 From: Sudeep Holla To: Dan Carpenter Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla Subject: Re: [bug report] firmware: arm_ffa: Add schedule receiver callback mechanism Message-ID: References: <0e8ddbca-d9da-4a3b-aae3-328993b62ba2@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0e8ddbca-d9da-4a3b-aae3-328993b62ba2@moroto.mountain> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231030_090117_796629_30C4ED0A X-CRM114-Status: GOOD ( 13.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 30, 2023 at 05:31:04PM +0300, Dan Carpenter wrote: > 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). Not sure if I am following this warning properly. I am bit confused whether it suggest 8 is correct or 88 is correct. Anyways, the expectation is to just allocate 8 bytes for a pointer. We just fetch a list of stored pointer in XArray and free them. One possible way to avoid any confusion is to use sizeof(struct ffa_dev_part_info *) or even sizeof(void *). > > 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. > Yes, that is the expected behaviour. We copy the pointers that were allocated in the setup and free them here. -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel