Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2718886rdb; Mon, 4 Dec 2023 05:55:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFc5ouk5KsE3KaWg46VRkZ5FTL4+EYMmbXAJR9nc0VCLg3lmf7Yqe6kOQQ6Jek5FebewYhA X-Received: by 2002:a05:6a20:3942:b0:18f:97c:b9fb with SMTP id r2-20020a056a20394200b0018f097cb9fbmr2600595pzg.85.1701698110792; Mon, 04 Dec 2023 05:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701698110; cv=none; d=google.com; s=arc-20160816; b=Kh9xNsq6KkDgN5Y5LwtCrx7jrki1wf04h5bnfL9zMYazP+QimUTEscV0noQWbsW1aC l0Fdgoiqji2RjVi1C6TtDTChIW6TI3fM66XvUupm52RX3QI8NYTJVHmpDeygYWjj+lwa 5r9Pmi6Sged1088fyii6AOlXY24Z/Pj9CVoynBaFsYos0XCholisGuhqMHqWlYZY+Bud ACriAt9T+MyebedXzNtKLRJY7XvvW43jPupLB2PvQENgiti2xByLoTpP/KSxsOZhlGvw q+lr75TzBP+c8JGBz9RCInXZuykmHqdQCzqWkBKbnhJhhbFzxLWgggTAo+LTLfgEOOuE n03Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=GI+qQgtpJOScngPDzV7Oi2GR8ngc03+abpZHiIiH2oc=; fh=O7lo0Aij/70p/xVuxDpdkniiROz9U8kwmV+Kd/oZY/U=; b=HrTqLxKWpgpdGYPyfT4jdvVIWotADUZTdtMRIw91gk1pDQ2ehQWw4y6spMEjwXfGLq eYd4L1XCoGKBTm1/V/rw/CepH+npbj28cqxR5MhMmNljv5PWP5TpWJwsP6vm8VeOlto4 O3rJuVJ+mZeYmK6YmvnC8IJn8KiCDQ8GCiNNVAiu22Z6mMUkQ4k5t5Cy+fcJQuEkGOso CUwc1YJjCvCCziLoFbAo35xV439l4qR95Pli29FaIeEOTUGEl8znePGtIu1rmRmnFRTG V/PiiIuFpNgcQgd4Pvkzwh8go+kXbwo9hLJmk8f8XldFGguJT0QsvL/BlwQGNwOpFMce /kyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eZ08aZ5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id a8-20020a056a000c8800b006cdf3e98118si6958580pfv.118.2023.12.04.05.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 05:55:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eZ08aZ5M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 58AEE805B325; Mon, 4 Dec 2023 05:55:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235697AbjLDNys (ORCPT + 99 others); Mon, 4 Dec 2023 08:54:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344800AbjLDNyp (ORCPT ); Mon, 4 Dec 2023 08:54:45 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA0C102; Mon, 4 Dec 2023 05:54:49 -0800 (PST) Received: from nicolas-tpx395.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nicolas) by madras.collabora.co.uk (Postfix) with ESMTPSA id 62C2E660711D; Mon, 4 Dec 2023 13:54:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1701698088; bh=PVA41weTM/0r0G0fLxhp7nE8jfHRfSplJAtdMTUdgZ4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=eZ08aZ5MePVxoXFWfBYnB3A5i11+zswsy2wL/1AOb+9/8NCNEEMAUaKS4Go3Z3469 HANX77Z6NZr0nuyGou6b3HGJOVvpc/JgdOrWBNj2GumIRSRfiGiO4jOJuolJ41rU4i ut1ks1YTprC9BxLz6Sap8zzObnYVM3xMEk9vtBIK8oY8APIH0970GFGxMqde+/+kGh ZMRDzUmUX5ndB199DPB5S5KZ5c0OJT8cRb7gZpTIrv0wh5xl7CVRmMNGAkXoVxhKSd 4sN1MArsB6j/s1aSHC3TvrN3jbExGgxp5fCNRZ9ojMZdSfuT5ecUAMvcGNJkyPtt3w b299/RnvKgJ4w== Message-ID: Subject: Re: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() From: Nicolas Dufresne To: Zeng Chi , nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com, mchehab@kernel.org, sebastian.fricke@collabora.com, hverkuil-cisco@xs4all.nl, bob.beckett@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 04 Dec 2023 08:54:37 -0500 In-Reply-To: <20231204083957.2835095-1-zengchi@kylinos.cn> References: <20231204083957.2835095-1-zengchi@kylinos.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 05:55:08 -0800 (PST) Hi, Le lundi 04 d=C3=A9cembre 2023 =C3=A0 16:39 +0800, Zeng Chi a =C3=A9crit=C2= =A0: > This patch fixes memory leaks on error escapes in wave5_vpu_open_enc() > and wave5_vpu_open_dec(). >=20 > Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer") > Signed-off-by: Zeng Chi > --- > drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 4 +++- > drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 4 +++- > 2 files changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/d= rivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > index 8b1417ece96e..2d3e8a184f93 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c > @@ -1792,8 +1792,10 @@ static int wave5_vpu_open_dec(struct file *filp) > int ret =3D 0; > =20 > inst =3D kzalloc(sizeof(*inst), GFP_KERNEL); > - if (!inst) > + if (!inst) { > + kfree(inst); The allocation failed, there is nothing to free here (kfree(null) is a no-o= p). This patch does not do what it pretends to do. Nicolas > return -ENOMEM; > + } > =20 > inst->dev =3D dev; > inst->type =3D VPU_INST_TYPE_DEC; > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/d= rivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > index f29cfa3af94a..cbf6cb6e07aa 100644 > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c > @@ -1537,8 +1537,10 @@ static int wave5_vpu_open_enc(struct file *filp) > int ret =3D 0; > =20 > inst =3D kzalloc(sizeof(*inst), GFP_KERNEL); > - if (!inst) > + if (!inst) { > + kfree(inst); > return -ENOMEM; > + } > v4l2_ctrl_hdl =3D &inst->v4l2_ctrl_hdl; > =20 > inst->dev =3D dev;