Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1003578iob; Fri, 13 May 2022 19:17:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS3ByBpATvPA1Hq+faZ/3km6+aCeeesZfRvg0Z7zpxaGukXODLumzIAaziDa0P/hldfUGJ X-Received: by 2002:a05:600c:a06:b0:394:8d3d:de68 with SMTP id z6-20020a05600c0a0600b003948d3dde68mr17788657wmp.18.1652494631269; Fri, 13 May 2022 19:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652494631; cv=none; d=google.com; s=arc-20160816; b=tqy+YOFoN+MTOf3NKqot+cZlE4/jG85f4xp+l7hZGVw6pY1MOMoo++/FQGpMe+Abl0 kj/rheORlC4hhlfMa+sfgbeaB5CRBCD9XMhfeUv3qy6sw/ASF8iYI0MBc2evJnypUmWy 740kN62dR3ZTItLv402bO01hia3vwMb9vDaNuBj+4kEAHo78g3dR4VJeSGYAJ6h/IDyd smh03lfp86g8axHyQB2gATVYpucZlflo4h9+NNjqa9cAdr5l+Gwk/ADwDbLv/uABjn+L dph17VpUeadrxTZb4X2CEu/6LEcMx69dBaDZoXME5Smc4JPfe1K4ZL0mgHgJP4u/Zpe8 Qb1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=86xMI6n0yNYvyAOIthvXNYWaEun83m6rQQQCzOlqHlE=; b=AGzKQTsuArumDrWtGGLzQNxf/1PeZ9t/xlk21JIHzrWmMTC/HNSnXTZ1T2bydOoI4j oy/naAwq+S2XUjzzxlOyrQZuSegb28sjQiWAOpMcaa5e7Qj6stXV8AVfkQd6VEtc9MM0 vNePrnpjTskzeozuHjOO9evcgEPHsoZI780d+xY9iejxoE5PxoNfdmoEaq32rdDseAgI nA81hsUj8YyhoKx8S7aELbkt350iXUyHfRPSKBsBOaC6fC+eXyHCnVL+HVQht/ftAk4J l4jhbCv8E5cpaT0oxgI0Ytr5OtdVid1JAZ3nfP5Jo5zC6O56GZKvw/Lq4PASQcaf6sDE gAlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=PfQaWywt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d5-20020a056000186500b0020c61461322si4963307wri.329.2022.05.13.19.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=PfQaWywt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE6064AD7EC; Fri, 13 May 2022 17:34:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378166AbiEMIXu (ORCPT + 99 others); Fri, 13 May 2022 04:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378091AbiEMIXt (ORCPT ); Fri, 13 May 2022 04:23:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E05B025B076; Fri, 13 May 2022 01:23:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7ED1562010; Fri, 13 May 2022 08:23:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7369C34114; Fri, 13 May 2022 08:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652430226; bh=VdFOgS93MTxgXl8MYQIAwcaYqU9bLXsKmrW93/ntJg4=; h=From:To:Cc:Subject:Date:From; b=PfQaWywtP3MmwhELVywMZUOkmEL1ASj8IdxGcQw4A2AK8y9PTl2RpYUycHBziE6oZ cfkbD35954X0w5scVzxeuNVU1Rr/4C1Qe9uFsQfSmcvBEJIuRk8mPRpHaQIJMLTqFu 5PCYI3bam5smrDfPvBAjEN0zYO3IyeYQPaR1Blco1qIoBjRZDME7+NyYPBK1ckpyGZ Z2tjR6wNNnsVyJTMzOI31w4Sz2l8+yhRHqOYOzBWL1g2qqDLP4G3pW9Gb3RRDKmObm PNW2e2G+67QipmYeuIZKfOh1qikOHSFLcwR09yvtIG0MaUtlL6lxODo20wuyNhDdeL nW68QlqAnl4Qg== Received: from mchehab by mail.kernel.org with local (Exim 4.95) (envelope-from ) id 1npQaO-003DpF-F4; Fri, 13 May 2022 10:23:44 +0200 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Greg Kroah-Hartman , Sakari Ailus , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH] media: atomisp: don't pass a pointer to a local variable Date: Fri, 13 May 2022 10:23:43 +0200 Message-Id: <671749e03ec7b4d7adf044745c0c55acf1a02358.1652430219.git.mchehab@kernel.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As warned by gcc 12.1: drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c: In function 'ia_css_rmgr_acq_vbuf': drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:275:33: error: storing the address of local variable 'h' in '*handle' [-Werror=dangling-pointer=] 275 | *handle = &h; | ~~~~~~~~^~~~ drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: 'h' declared here 257 | struct ia_css_rmgr_vbuf_handle h; | ^ drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c:257:40: note: 'handle' declared here cc1: all warnings being treated as errors The logic uses a temporary struct to update the handler, but, instead of copying the value to the pointer sent by the caller, it replaces it with the content with a local variable. That's wrong, and may lead the caller to use a weird value. Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c b/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c index d96aaa4bc75d..39604752785b 100644 --- a/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c +++ b/drivers/staging/media/atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c @@ -254,7 +254,7 @@ void rmgr_pop_handle(struct ia_css_rmgr_vbuf_pool *pool, void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool, struct ia_css_rmgr_vbuf_handle **handle) { - struct ia_css_rmgr_vbuf_handle h; + struct ia_css_rmgr_vbuf_handle h = { 0 }; if ((!pool) || (!handle) || (!*handle)) { IA_CSS_LOG("Invalid inputs"); @@ -272,7 +272,7 @@ void ia_css_rmgr_acq_vbuf(struct ia_css_rmgr_vbuf_pool *pool, h.size = (*handle)->size; /* release ref to current buffer */ ia_css_rmgr_refcount_release_vbuf(handle); - *handle = &h; + **handle = h; } /* get new buffer for needed size */ if ((*handle)->vptr == 0x0) { -- 2.36.1