Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2393079rwr; Fri, 21 Apr 2023 08:17:16 -0700 (PDT) X-Google-Smtp-Source: AKy350Y2nMovA0EKJAF7Bsxlga2rVZCk7Pe9JEnhNU68q0bIB8U8xZT98/ubHxXfCluRrjA3XQww X-Received: by 2002:a17:90a:1a01:b0:24b:5ebd:56c3 with SMTP id 1-20020a17090a1a0100b0024b5ebd56c3mr3094047pjk.2.1682090236140; Fri, 21 Apr 2023 08:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682090236; cv=none; d=google.com; s=arc-20160816; b=qsREeTSSa5OPW3+Y76Zw4HN51ui518DD7ZQHTpnlSc2d3V3RV+FUBys5jLgtVIbHMU zV2VOAzdaRbLCNvd9xc3D4VWejD1FEGo5mOpgi6CeV4udmUK5Ua9P2ZZpiJWM8Il7CNd aGFchQ8WMwo5HG2YIPif90S9gh3ExlXTYJyuHc5Z/knWb2H/PKvwIAywoXVI4vyh/aCh RjnN8XfWp1uC96zeEpIPOK8jY/JbT+tRSdSXI8r25/5qt3nW142/u8XGI3JBOS5E7uW3 dxUInKiqG5wd+Q+oWy/wR2RiwakcGBpQ6HaHZOqWjpfKC3pBiIpYLtZ06u3HUmG4hi9y VsZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ttfYzJPyGkvXU/IjTHs11yMYKVw3msy4/Cy81RSX6fQ=; b=uZaltriqIEUr3U3uYKpS45njAc9LkGZVVKpI2Hvi5Rzc1G9YPfoxm3YL+RrB7ZBa32 h4WnxWENnF3lh629J7wmxaaRtxhlfRWyPRz/9yq+O40ua6idG/oZNmOJmR2/2g2H7DvM QgnnAPWVn+x/oRAYtGkzVOjhOlVBvWLx/eWqAxWlumHpXd5B5NqMAXXBTrgksdkaMpRN TTwY5eoDUFqgDzVQdzGpfRWul9HDjdbEG/xqCDWMiJgrxoGkAsSWRXck1VHsv665ompQ W+5zrcOgykK4eGQZRImmRvaoRFTMk3ugJkYhsoZOHHdAliBLiX5daGT+Y4HUeUOTfG4o tl3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AA1N0siP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my17-20020a17090b4c9100b002474ff0aee3si8042549pjb.150.2023.04.21.08.17.00; Fri, 21 Apr 2023 08:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AA1N0siP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbjDUPIj (ORCPT + 99 others); Fri, 21 Apr 2023 11:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbjDUPIi (ORCPT ); Fri, 21 Apr 2023 11:08:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5302D49 for ; Fri, 21 Apr 2023 08:08:37 -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 E9F5F61475 for ; Fri, 21 Apr 2023 15:08:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99F95C433EF; Fri, 21 Apr 2023 15:08:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1682089716; bh=1i7j+X46zvSlI6Z+TMWDeqVeOCFHR1IVigQcStEkzH8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AA1N0siPr1NrFT1Ip0ph8FAyQLTqMG2B9SBxBsb7eUH7X7iXCjSPDUa5yJxKFhI+a 5MvtYuC9M9CL+4Gi6cb88NtS64WNOliJK92OWfwpBf7tVf6z5umaLOzwkG/1LLHbOH c7VBfw0XituE9xg5Z7m0Z1sw4K7sSxmdcH4gKI6w= Date: Fri, 21 Apr 2023 17:08:33 +0200 From: Greg Kroah-Hartman To: Mirsad Goran Todorovac Cc: Luis Chamberlain , Russ Weight , linux-kernel@vger.kernel.org, Tianfei zhang , Christophe JAILLET , Zhengchao Shao , Colin Ian King , Takashi Iwai , Kees Cook , Scott Branden , Dan Carpenter Subject: Re: [PATCH v4 1/1] test_firmware: fix some memory leaks and racing conditions Message-ID: References: <20230421145700.20931-1-mirsad.todorovac@alu.unizg.hr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230421145700.20931-1-mirsad.todorovac@alu.unizg.hr> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 21, 2023 at 04:57:01PM +0200, Mirsad Goran Todorovac wrote: > Some functions were called both from locked and unlocked context, so > the lock was dropped prematurely, introducing a race condition when > deadlock was avoided. > > Having two locks wouldn't assure a race-proof mutual exclusion. > > __test_dev_config_update_bool(), __test_dev_config_update_u8() and > __test_dev_config_update_size_t() unlocked versions of the functions > were introduced to be called from the locked contexts as a workaround > without releasing the main driver's lock and causing a race condition. > > This should guarantee mutual exclusion and prevent any race conditions. > > Locked versions simply allow for mutual exclusion and call the unlocked > counterparts, to avoid duplication of code. > > trigger_batched_requests_store() and trigger_batched_requests_async_store() > now return -EBUSY if called with test_fw_config->reqs already allocated, > so the memory leak is prevented. > > The same functions now keep track of the allocated buf for firmware in > req->fw_buf as release_firmware() will not deallocate this storage for us. > > Additionally, in __test_release_all_firmware(), req->fw_buf is released > before calling release_firmware(reqs->fw) foreach test_fw_config->regs[i]. > > Cc: Greg Kroah-Hartman > Cc: Luis Chamberlain > Cc: Russ Weight > Cc: Tianfei zhang > Cc: Christophe JAILLET > Cc: Zhengchao Shao > Cc: Colin Ian King > Cc: linux-kernel@vger.kernel.org > Cc: Takashi Iwai > Cc: Kees Cook > Cc: Scott Branden > Cc: Luis R. Rodriguez > Suggested-by: Dan Carpenter > Signed-off-by: Mirsad Goran Todorovac > --- > lib/test_firmware.c | 81 +++++++++++++++++++++++++++++++++++---------- > 1 file changed, 63 insertions(+), 18 deletions(-) > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot