Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2370030lqo; Mon, 20 May 2024 03:55:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpbnM8Hs3R2+i0RMYO29wcqERO0cEsOzML4VDR0gdg0vOcGLdn0zwU21SLVya6dBcAD2Hp/MGKHB3j8ITMAQ9XjSewSYiATXtbt/xXig== X-Google-Smtp-Source: AGHT+IFwcukiRioLkqgCIStN0cKjEk5zoQoVDwVmIHfvsr6A7eFE20UFVCLRTyxoBaNcy6sjczuR X-Received: by 2002:a17:903:190:b0:1f3:134:533a with SMTP id d9443c01a7336-1f3013468famr27257885ad.28.1716202543945; Mon, 20 May 2024 03:55:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716202543; cv=pass; d=google.com; s=arc-20160816; b=AD+W1Cl9fJK49lGRgJ7L26pAKSAu6qq6vpWJ6Qt/XxjrBg0NSIlizNZp0DHeNqhEiq aFNRIHztgb1nS0i714sLewP2LwHUHILGRMlsWV1JJcBT6CHtttWZHS1/yOPj0AO60VSN Bb2rWAvK/Mu18S+pYx11ReygTEwFHYmcUI8EwFjzL5woEKTmIa0mzIyVEcJreN82XO81 8zauCMFR6cISp6Xhw9Pkmt5ELwV+6SRbrqLGebYo4x6ohYeQFttllVE9e5bV7FCninf3 CBNAV3OCbtQY73l2H0UjTsDgPFRIGM7YpxuUczHdrC2kZ6TU+nS1EtvBjWRSAHsngYFV UAbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=ELn5yy0YtZNkzllyxlQxOp3Ewnx5JI4zkxA511+HSiI=; fh=mRRApEHpi1mAPv1jmPesEqYFHcUIiA3+lMpLKia/scY=; b=D8o0ZBNVWXAOgCeHlasmiuRdivuZ9q8Us7XuNRvRQ7102sUer5bOQkC8Z6Em4MChMx gzzz8hf0AuvPQKyfREA/1BXukjZpaXC1Zb1JPViaeL1el1a4/dh8g2FH1m7xkIJ9NAzo QxNdXfSG/ctAr2h1HL8XJHSJdFxhzj12nqQhoXHv7LNS/11oIrEcvUJfF7EvlO35Iolh aLtObkCqeOwo9uibZVhftajHLFjujG0XCVLDB6cOuCE9CUxttJJVc5YPfgQQEdlg9l5M 5/hMrAX/x8TAn2gyT1l8YHgFufGmblY2LEyujuLXyo02S4npmenpRvwkVuhxC6qjjgoa 571A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=VCej1KKe; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-183632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f30449be10si11829575ad.239.2024.05.20.03.55.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 03:55:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=VCej1KKe; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-183632-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183632-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 66FACB227CC for ; Mon, 20 May 2024 10:55:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A6605381D; Mon, 20 May 2024 10:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="VCej1KKe" Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC8A182DF; Mon, 20 May 2024 10:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716202509; cv=none; b=piSwoJk4C03uACKNA+TgRaHg0wP4DG3ocwukiJtCFaQElpWm+mKORv6X/Q5Y2TLWZ7Q5XSk/qlYb1HummdrAu3T+z0Eok68pf2CoMZfcz+6iciXex7fASh9VbIs5GLjumg+PHczodnIiZNeqebORWJ7sDUVHbNV8hLYHgxBResE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716202509; c=relaxed/simple; bh=q3bRoEZ79xHc4f0wx00Hbe+TL94wH3IqUYcu0JWlp4Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DFKHtq8IGJEOisl0i+i5sNJvRDEEdGK3JviVzuxxf1A8yXIxqSrDH4XBGxPsRCklI0plpoN8P+1Ah/05Om5i95Cmrl7od4yFaoLJ4tfjgLq5dD34AuBMslfwjof8KV9NBDlQazM6ICveOrJxPKb1NjXiLTyl2Iu1lW5/mNSBZK8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=VCej1KKe; arc=none smtp.client-ip=80.12.242.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from [192.168.1.37] ([86.243.17.157]) by smtp.orange.fr with ESMTPA id 90e5sSJgC8l3290e5srEL3; Mon, 20 May 2024 12:53:35 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1716202415; bh=ELn5yy0YtZNkzllyxlQxOp3Ewnx5JI4zkxA511+HSiI=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=VCej1KKervtWUMm/8Z4jxCbaPOxAqUi9V9la6FaH71gK757Mfoif7XYSvSHyDmwYW zs8gy1CuvVXFBAgjobcxiqnCzeANLoEX/pvRKwsB2zMhRP4/NQ9YkqKnwyk0bvcNxo 30haz0K1faiRKeYjiHmIKvmJeNLjYLb4J+shQYCgF69neg6SiAiSXsZ9FCAKQysvKr nRnqCOi+MD020RpgEstfi2aogIFus8qEBOfHUVYy9y9Rq+62AGTk0QTssBILvLUbJZ CI3fiposyxKr0y4jAD4UBa7AkFSpEHC0yT8zGXF4qhKh6BA9Gh3zee0m6b3bH0qkpb BCM+YuaqdOrnA== X-ME-Helo: [192.168.1.37] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 20 May 2024 12:53:35 +0200 X-ME-IP: 86.243.17.157 Message-ID: <68377fae-d6be-4658-ad4a-c9df8c3548d7@wanadoo.fr> Date: Mon, 20 May 2024 12:53:46 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] media: intel/ipu6: Fix an error handling path in isys_probe() To: Sakari Ailus Cc: Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Hans de Goede , Hans Verkuil , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-media@vger.kernel.org References: <545315bcaac0a897c25cfa20a603be2af2a40aa9.1716201136.git.christophe.jaillet@wanadoo.fr> Content-Language: en-MW From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 20/05/2024 à 12:47, Sakari Ailus a écrit : > Hi Christophe, > > Thanks for the patch. > > On Mon, May 20, 2024 at 12:32:30PM +0200, Christophe JAILLET wrote: >> If an error occurs after a successful alloc_fw_msg_bufs() call, some >> resources should be released as already done in the remove function. >> >> Fixes: f50c4ca0a820 ("media: intel/ipu6: add the main input system driver") >> Signed-off-by: Christophe JAILLET >> --- >> Compile tested only >> --- >> drivers/media/pci/intel/ipu6/ipu6-isys.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c >> index 5992138c7290..d9e1e1a135b9 100644 >> --- a/drivers/media/pci/intel/ipu6/ipu6-isys.c >> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c >> @@ -1062,6 +1062,7 @@ static int isys_probe(struct auxiliary_device *auxdev, >> const struct ipu6_isys_internal_csi2_pdata *csi2_pdata; >> struct ipu6_bus_device *adev = auxdev_to_adev(auxdev); >> struct ipu6_device *isp = adev->isp; >> + struct isys_fw_msgs *fwmsg, *safe; >> const struct firmware *fw; >> struct ipu6_isys *isys; >> unsigned int i; >> @@ -1140,12 +1141,17 @@ static int isys_probe(struct auxiliary_device *auxdev, >> >> ret = isys_register_devices(isys); >> if (ret) >> - goto out_remove_pkg_dir_shared_buffer; >> + goto free_fw_msg_bufs; >> >> ipu6_mmu_hw_cleanup(adev->mmu); >> >> return 0; >> >> +free_fw_msg_bufs: >> + list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) >> + dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs), >> + fwmsg, fwmsg->dma_addr, 0); > > This is also done in isys_remove(). How about moving these into a new > function that releases memory from both lists? I agree. I thought about that too but decided to propose a simple solution first. > > There's no harm in traversing framebuflist_fw as well, it's empty at this > point. Yes, that's my understanding. That's why I only copied one list_for_each_entry_safe(). I'll send a v2 with the list_for_each_entry_safe() in a new function. It will be much cleaner. CJ > >> + >> out_remove_pkg_dir_shared_buffer: >> if (!isp->secure_mode) >> ipu6_cpd_free_pkg_dir(adev); >