Message ID | 20230327115809.297633-1-harperchen1110@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1462444vqo; Mon, 27 Mar 2023 05:14:02 -0700 (PDT) X-Google-Smtp-Source: AKy350ZZ8NTqv3k4c8jQqPzzsBB6CmRHepNXx0O+x5ujoMRqIyhw39Tjtx6xpxeY7LmAATECp8ef X-Received: by 2002:a17:906:3093:b0:931:6641:9897 with SMTP id 19-20020a170906309300b0093166419897mr11698331ejv.44.1679919241850; Mon, 27 Mar 2023 05:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679919241; cv=none; d=google.com; s=arc-20160816; b=hfx3TYCT25MT48kEMYZZm84nnEMBiq2GWOglhCm2RTnwoI8auKJz/p9QWou6G9+J39 yw/2N2wFhxLI15xhHeANOaZowx+3foHujJdYNlS6xt8Ra/kTkjR2WsxT56/s1dowxLc/ 9qlIvOQHaP6WXfThtTNVE9vZ1p1Rs6G8h5YXIZIycGx++KHFwQ8ery0lwKpTejcItnR0 0T26m3U1NSnrfKJE6SH2kp9PqekG/osMAz9Rjt4I2mCSpiNKwXjK4iHpfxJjLD/VqNQO X0HqZuHNhmaGVm54bx0nQEM5DYemByX2D9DuppKkc7lHOzZ64K4bryHIj3kmmiVF+31+ pr2g== 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:dkim-signature; bh=Doe7pet32ZDC5C9QjTizakUZOQlL9yMgkyH48O/Iy/I=; b=ybJIongwk+qHJWtbR/f7Xa3/COo8Byj1DOqP7R9fOP45UdDKCJZqERhloDoGKXEh8Z bomWdmmj5u3VZj77hwa9k/7w2TflaNwvHHW7ti0bhecrCuzT3JHj4+3u/B0YtNfddu8G l4UEWdFDnz0IcZMds5ouCxcqQIHppNM3yql78PgAo7diS5FRNbIEq0Z0NNjbEWck3tB5 DyOR4WUni7E82G7eCCyPySdgbhqeNh0eNwtieH77F7hTbM4/TEudPVCXq2GKv4SZwkj9 mhsIF8e9gQKZ8qos7D+G1rqrPELxUMt4c0KszzBKKq2Ucu59qLJdEvHuLycxeMU/buy7 Rz0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=o+oGoEDi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg6-20020a170907a40600b00944a52dd3b9si3041982ejc.452.2023.03.27.05.13.38; Mon, 27 Mar 2023 05:14:01 -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=@gmail.com header.s=20210112 header.b=o+oGoEDi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232221AbjC0L6V (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Mon, 27 Mar 2023 07:58:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjC0L6U (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 27 Mar 2023 07:58:20 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3A993584; Mon, 27 Mar 2023 04:58:19 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id p15so10141529ybl.9; Mon, 27 Mar 2023 04:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679918299; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Doe7pet32ZDC5C9QjTizakUZOQlL9yMgkyH48O/Iy/I=; b=o+oGoEDiS+zRLyaaaVxnV3wlt3U5HBn5fGnGvwWJLsabKUb5mT2qVG28j4HvYY/+MB O/RblVI12IaO7Z5k7vdonKSz1k3/n+3IENiAe9KNZqRWl1oAmIPgI6ij6ZO34w62FAVC nZwI/grBgdid1+zXMd9vN1fHo1OQwMp+9EsJrAJ+Jju89ixByJxejq09Tg5QvzfbqGlJ YINAsA6/DvYHh/Lgu5Py0znucFJerZxpca5qsXu6/77Drw1GY96GTnwgF6g0/9Q/DRqB yEQITJr8Us7eayS9tn7mFXZYOoGMIAw3fGZMPkVFNtplaK+6SiAzF4AUohQm2ZcN7lbg RQwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679918299; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Doe7pet32ZDC5C9QjTizakUZOQlL9yMgkyH48O/Iy/I=; b=71+Edgb4pA+iTPmi6uJEEHxjuZXGM0Ccz7S12NG0C60t3FMpydiRGrvAeL6yIvspYM IEpCNFOH+9kFfGkY0zzmF548CVuGNYz/0h6KeiC02QWOVDjrZNre+tnyDyiAGBJcCsGe XOQVbDR6BSNlhYUerZj9h9mXF23laZOnu/GCtCEw8P0sWz1P6J/epuGG+kBxoer+GsxO xQ1WVecfWvL8LCr2bD7LCxcvxELZlBv4wFc4Ggwz6rIIQM0eqYIABlKON4/bOJs3199b 9QX4reKeEHL/A3flwoQEkeKKyKZm/jJvqQHUx/gMlBqKHCrsQ7AYJ+zbodt/1gM93Lw7 4Xcw== X-Gm-Message-State: AAQBX9c2OZFgPMY4bxeXE0QLOrm4adaeSI/4BZnDExsKL4ZLYmlbLBXU wq7i8rSKgGXP1Fd+qmG2w7nhyBLZkFT4yw== X-Received: by 2002:a25:f609:0:b0:b68:129b:6127 with SMTP id t9-20020a25f609000000b00b68129b6127mr11336593ybd.50.1679918299134; Mon, 27 Mar 2023 04:58:19 -0700 (PDT) Received: from chcpu13.cse.ust.hk (191host119.mobilenet.cse.ust.hk. [143.89.191.119]) by smtp.gmail.com with ESMTPSA id i8-20020a255408000000b00b7767ca746bsm2243730ybb.8.2023.03.27.04.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 04:58:18 -0700 (PDT) From: Wei Chen <harperchen1110@gmail.com> To: martink@posteo.de Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Wei Chen <harperchen1110@gmail.com> Subject: [PATCH v3] media: hi846: Fix memleak in hi846_init_controls() Date: Mon, 27 Mar 2023 11:58:09 +0000 Message-Id: <20230327115809.297633-1-harperchen1110@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761522998962669456?= X-GMAIL-MSGID: =?utf-8?q?1761522998962669456?= |
Series |
[v3] media: hi846: Fix memleak in hi846_init_controls()
|
|
Commit Message
Wei Chen
March 27, 2023, 11:58 a.m. UTC
hi846_init_controls doesn't clean the allocated ctrl_hdlr
in case there is a failure, which causes memleak. Add
v4l2_ctrl_handler_free to free the resource properly.
Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 8M pixel camera")
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
---
Changes in v2:
- move v4l2_ctrl_handler_free to error tag
- handle memleak in other failure positions
Changes in v3:
- add fixes commit tag
drivers/media/i2c/hi846.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
Comments
Am Montag, dem 27.03.2023 um 11:58 +0000 schrieb Wei Chen: > hi846_init_controls doesn't clean the allocated ctrl_hdlr > in case there is a failure, which causes memleak. Add > v4l2_ctrl_handler_free to free the resource properly. > > Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 > 8M pixel camera") > Signed-off-by: Wei Chen <harperchen1110@gmail.com> just for the future: you don't need to send a new revision for tags- addition only. That's usually something that maintainers can do when applying, also (semi-)automated. But *if* you send a new revision (due to other changes), you *should* add all appropriate tags. So for this new revision you forgot this: Reviewed-by: Martin Kepplinger <martin.kepplinger@puri.sm> but, as you now know, you should not create a new revision for this alone. thanks, martin
diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c index 7c61873b7198..f86997a261f5 100644 --- a/drivers/media/i2c/hi846.c +++ b/drivers/media/i2c/hi846.c @@ -1472,21 +1472,26 @@ static int hi846_init_controls(struct hi846 *hi846) if (ctrl_hdlr->error) { dev_err(&client->dev, "v4l ctrl handler error: %d\n", ctrl_hdlr->error); - return ctrl_hdlr->error; + ret = ctrl_hdlr->error; + goto error; } ret = v4l2_fwnode_device_parse(&client->dev, &props); if (ret) - return ret; + goto error; ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &hi846_ctrl_ops, &props); if (ret) - return ret; + goto error; hi846->sd.ctrl_handler = ctrl_hdlr; return 0; + +error: + v4l2_ctrl_handler_free(ctrl_hdlr); + return ret; } static int hi846_set_video_mode(struct hi846 *hi846, int fps)