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 6FC71C4332F for ; Tue, 31 Oct 2023 09:52:27 +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=duHmQaHQOGsV8jUCVlU5ng7HJvLUM+F9JK4PJuW7ZZI=; b=0YYbNH5Ra2S2hE Gg51dwTpo2Q8sGgY3tO8ktKsFL5kk03shBAGbpvHKeZrKPsfgcqCofof7WmBt6ZVKfdlEE1eL/Eb+ fLbDaLRLm/58SzpFCo9JX63k0aHo+46tTT93/I4QaESd8vhXvbvGXh2uM3Gfg4SwbUBKMVm1vNMaD Vo5Q/0j++PRyg6h7o2g7yhW/TdV+RsgzeD83J+OFtt75W1jleY7S8DCQN6WTR5xOlqhEpTvRk/+AB qArPCdzKNAsnoek2mN+LXyir+6l2VnAiwWCoui2VGP94m0WTBqpMPOy9MwkuQEP9Nj/ohRlpojZgq 5dY6FtAA0jk8k4lR+YSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxlPn-004uWv-2U; Tue, 31 Oct 2023 09:52:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxlOd-004ts2-1Y for linux-arm-kernel@lists.infradead.org; Tue, 31 Oct 2023 09:50:52 +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 02909C15; Tue, 31 Oct 2023 02:51:32 -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 AD8103F67D; Tue, 31 Oct 2023 02:50:49 -0700 (PDT) Date: Tue, 31 Oct 2023 09:50:47 +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> <5ff13821-5b37-4dca-90ee-7fa54f7adffa@kadam.mountain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5ff13821-5b37-4dca-90ee-7fa54f7adffa@kadam.mountain> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231031_025051_566803_1F17C361 X-CRM114-Status: GOOD ( 21.42 ) 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 Tue, Oct 31, 2023 at 07:15:45AM +0300, Dan Carpenter wrote: > On Mon, Oct 30, 2023 at 04:01:07PM +0000, Sudeep Holla wrote: > > 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 *). > > The static checker is saying that 8 is correct but we are allocating 88 > bytes. OK 88 bytes was bit misleading for me initially but then realised that when all the debug options are enables rwlock_t is 72bytes instead of 8bytes. I was expecting 24 bytes in place 88 bytes. > There is an extra * in the sizeof(). > That said, I was completely blind about this. Sorry for that, clearly a type that got missed so far. > I don't necessarily like to make buffers smaller in case I have > misunderstood the code, but it seems like we should do that here. > Agreed, sorry as I said I was confused with the report for other reason as mentioned above as well as blindness to the typo I have made :D. I will send a fix soon. -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel