From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234517AbiHPKZS (ORCPT ); Tue, 16 Aug 2022 06:25:18 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 636A582853 for ; Tue, 16 Aug 2022 01:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : content-type : in-reply-to : mime-version; s=corp-2022-7-12; bh=37bWsy6m0fBAZIaP/56LFHZ6CASKn8tX/VFCwteKL6c=; b=WC7RJXYM8c7a1J7QBgczUpHcvkdWBhrLSQW5ILnwpG7nG9gaQx4yMpa5KCrPx2uSVWGw FH16P5RnO9IikEX6yCSIfGPOuFnB19DZezTQJxfRpu+mCEa9pTJLgOW4pXtWgyFjIla7 BiEpSME2PwqDXAA9x8TDjuMAwkTLZq1YRtC8NN5VgJNKJBuUBZ/Rf+tOErIMvroIDll2 ip+O6KKSwTUN1bexWAiCoOv3glwB494E+7XpJmsMIIrpDI5UzA5Q9foeAOd2bgfGYESe 36hCQkC8RZJnhRHaJ/nu0L4CgPG77RfyXuJmiBBMYe/RKNSDKsDvUL936rrXIVTembbN QQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37bWsy6m0fBAZIaP/56LFHZ6CASKn8tX/VFCwteKL6c=; b=XkuaKwqb1j/4lqg2PBEdenPx6uDaihO6rXaAxXUaohZ4vlWR0VFk45dTJ+PNQcbtDSiHzfzEmNNFREyTU41lhhw1vT4v0JUCa3/ox/CJxGtVg+VEvvHcHWdAptLgOnz25zc3F2F3HaXW9n/CJh+N3fITEKUsEYYwzTIl74I/sOs= Date: Tue, 16 Aug 2022 11:10:18 +0300 From: Dan Carpenter Subject: Re: [PATCH 1/2] smatch_allocations: Record the function that allocates memory Message-ID: <20220816081018.GP3438@kadam> References: <226fb08b3a13fd24f0739ab63bff369718003119.1660580395.git.christophe.jaillet@wanadoo.fr> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <226fb08b3a13fd24f0739ab63bff369718003119.1660580395.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 List-ID: To: Christophe JAILLET Cc: smatch@vger.kernel.org On Mon, Aug 15, 2022 at 06:20:55PM +0200, Christophe JAILLET wrote: > Keep track of the name of the function that did the memory allocation. > > Signed-off-by: Christophe JAILLET > --- > Not sure if it is the best way to save this information. Maybe it can > already be retrieved another way (from expr directly?) > You could get it from the expr. The expr is an assign expr foo = kmalloc(sizeof(*foo), GFP_KERNEL); So you could do: while (expr->type == EXPR_ASSIGNMENT) expr = strip_expr(expr->right); if (expr->type != EXPR_CALL) return; name = expr_to_str(expr->fn); At the same time putting it in the allocation_info feels like it might be the right thing and it's basically no cost so I'm going to apply this. regards, dan carpenter