Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86DD9C433EF for ; Wed, 12 Jan 2022 02:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348135AbiALCDu (ORCPT ); Tue, 11 Jan 2022 21:03:50 -0500 Received: from smtp25.cstnet.cn ([159.226.251.25]:34444 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231477AbiALCDt (ORCPT ); Tue, 11 Jan 2022 21:03:49 -0500 Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-05 (Coremail) with SMTP id zQCowADHz3_yNt5h0UsNBg--.14389S2; Wed, 12 Jan 2022 10:03:30 +0800 (CST) From: Jiasheng Jiang To: hverkuil@xs4all.nl, dwlsalmeida@gmail.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] media: vidtv: Add the missing kfree to avoid the memory leak Date: Wed, 12 Jan 2022 10:03:29 +0800 Message-Id: <20220112020329.692004-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowADHz3_yNt5h0UsNBg--.14389S2 X-Coremail-Antispam: 1UD129KBjvdXoWrurWftFWUZryUCFy3KF1xXwb_yoWfJFX_ua 9xXrn7WryUGryrKw1DtrykZryIkaykWr95X3ZIq34SyFy7uF1xJ342vr17Ga129FWjgFZr A343tF1fCrn7GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb4xFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr 0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8 JwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4U MIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUgVyxUUU UU= X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since kstrdup() allocate a space for e->name and will not automatically free. If kzalloc() fails, we just kfree e without e->name. Then we cannot get the pointer 'e->name' and cause the memory leak. Fixes: 3d1387b3b8f6 ("media: vidtv: fix some warnings") Signed-off-by: Jiasheng Jiang --- drivers/media/test-drivers/vidtv/vidtv_s302m.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c index ddaff46c440f..433fc0c7fdfa 100644 --- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c +++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c @@ -474,6 +474,7 @@ struct vidtv_encoder ctx = kzalloc(priv_sz, GFP_KERNEL); if (!ctx) { + kfree(e->name); kfree(e); return NULL; } -- 2.25.1