Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2580786rdb; Mon, 4 Dec 2023 01:17:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzZ+VqNZ5G3O29phvWswSGZw8vhg3AKj5tWaKrpnDNQb6tQkPyzZkzvV1EATcpFEHgaKUR X-Received: by 2002:a17:902:a9c3:b0:1d0:6ffd:f21d with SMTP id b3-20020a170902a9c300b001d06ffdf21dmr948185plr.115.1701681451096; Mon, 04 Dec 2023 01:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701681451; cv=none; d=google.com; s=arc-20160816; b=RpgheC+ULyFqD5XjIN7+JriXn81tys620qUGKwcNGhKzQG4lQMhYLkQgWSvrloTvR0 CqpTCs37yQpWR6BJefR1MHKbxjEY8xMuY0qTuH5XcyJqlCZiP1P08XfZZKpeY7RLyWPx 5w1oj/dyFTT8MssimjSdS1OFy6v4RlHgxQrhh4tQ5xfKC5FILpK0gQokQmmpPe7QVelQ 13uWyPF2398aWfZIvOBucxD009TGXSvgM0gUF3iqDiSjRjx0Wg+yhMZJJzBhIWolOQM4 tB2tpkd/DzbotubNba9wWmPXsHdjEMyrb0O9ksJU4cy99TAfhLUbXbzjCc0ZqTmvdElu HyJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=rBzdsTfsZK2Inkm2yJjC5zkiayOVmJxjtCV4FcZ0Mtg=; fh=eBhRUjn2AaVNHeGVenOk+fLSPaT/JS7Ukv037e8ED/c=; b=g7+h6MKnJ3MG9Q2XEAG6ZDxAY7uv9och6telSqAHayoKm/Wft5nvjeTMtplpauO2ny TUmPGOgtjHS+CvNNyIGDNuQAvl7IkTmehXYTI33bK4npKs95sTPfsvTtivJnhtgN/HZK UCa1RKRqWc4HX4T5HJyMf7G7pRnxkWtgE9Rw9K559rPsV5z5FUqyrlyDaR2Ikd67Fhk/ 0BNbJGYpxsZb391PZvrohHFXLm1/xjKhXErgFuvHA/PPfEkE0CewR82mPRDT3SXDz/Gx 4mo5c2dfnxYkAoxOEJ8LzbFBJKomd2ApzNIMlnaVUSGpcq2CyOLdlt+RMzq5LPZucvqO Tlgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d8-20020a170903230800b001cfdd05b5a3si7908963plh.434.2023.12.04.01.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:17:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C3B8280597AA; Mon, 4 Dec 2023 01:17:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjLDJRP (ORCPT + 99 others); Mon, 4 Dec 2023 04:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjLDJRN (ORCPT ); Mon, 4 Dec 2023 04:17:13 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D3B010E; Mon, 4 Dec 2023 01:17:12 -0800 (PST) X-UUID: b2dd1cfb302648d6995e901358889f68-20231204 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:f37ac697-bef6-4a90-bbfa-bc0369ecf577,IP:15, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:10 X-CID-INFO: VERSION:1.1.33,REQID:f37ac697-bef6-4a90-bbfa-bc0369ecf577,IP:15,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-5,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:10 X-CID-META: VersionHash:364b77b,CLOUDID:6c2143fd-4a48-46e2-b946-12f04f20af8c,B ulkID:231204164052U6WTZBVA,BulkQuantity:4,Recheck:0,SF:66|38|24|72|19|44|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: b2dd1cfb302648d6995e901358889f68-20231204 X-User: zengchi@kylinos.cn Received: from localhost.localdomain [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 895367361; Mon, 04 Dec 2023 17:16:58 +0800 From: Zeng Chi To: nas.chung@chipsnmedia.com, jackson.lee@chipsnmedia.com, mchehab@kernel.org, sebastian.fricke@collabora.com, nicolas.dufresne@collabora.com, hverkuil-cisco@xs4all.nl, bob.beckett@collabora.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, zengchi@kylinos.cn Subject: [PATCH] Fix memory leaks in wave5_vpu_open_enc() and wave5_vpu_open_dec() Date: Mon, 4 Dec 2023 17:16:49 +0800 Message-Id: <20231204091649.3418987-1-zengchi@kylinos.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 01:17:28 -0800 (PST) This patch fixes memory leaks on error escapes in wave5_vpu_open_enc() and wave5_vpu_open_dec(). 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 | 5 +++-- drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c index 8b1417ece96e..b0a045346bb7 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c @@ -1802,9 +1802,10 @@ static int wave5_vpu_open_dec(struct file *filp) spin_lock_init(&inst->state_spinlock); inst->codec_info = kzalloc(sizeof(*inst->codec_info), GFP_KERNEL); - if (!inst->codec_info) + if (!inst->codec_info) { + kfree(inst); return -ENOMEM; - + } v4l2_fh_init(&inst->v4l2_fh, vdev); filp->private_data = &inst->v4l2_fh; v4l2_fh_add(&inst->v4l2_fh); diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c index f29cfa3af94a..bc94de9ea546 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c @@ -1546,9 +1546,10 @@ static int wave5_vpu_open_enc(struct file *filp) inst->ops = &wave5_vpu_enc_inst_ops; inst->codec_info = kzalloc(sizeof(*inst->codec_info), GFP_KERNEL); - if (!inst->codec_info) + if (!inst->codec_info) { + kfree(inst); return -ENOMEM; - + } v4l2_fh_init(&inst->v4l2_fh, vdev); filp->private_data = &inst->v4l2_fh; v4l2_fh_add(&inst->v4l2_fh); -- 2.25.1