From patchwork Fri Sep 22 11:55:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Katya Orlova X-Patchwork-Id: 143507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5666541vqi; Fri, 22 Sep 2023 08:30:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzhG8OBStFnbWOMiPX+Cy0tQVUteU+iQw31vkLUhU4AnSYu+T8RUPlk7A1EHXCHeviQFKX X-Received: by 2002:a17:902:db0d:b0:1c3:f572:6701 with SMTP id m13-20020a170902db0d00b001c3f5726701mr10641362plx.45.1695396607783; Fri, 22 Sep 2023 08:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695396607; cv=none; d=google.com; s=arc-20160816; b=VSDUadtGbJhRBcaB5+ZCcKEJ/13/0tkl861uRhIIHTv2BQCPBoLC1nYQ4KWqS2IvzO HsXyReciMFAaQrE3GIYStfkdrbmM6Dq8KIgVFpK7C9ZThrWuy14Zifwmd29aEkGFhCsd sOO7WZ7m16pBX9MfnNAvRa/E+gVDpD4EVTHWckqs09C2gZG6BQzESlVYkBrn66xhP0un IpNRnQjaWBnRET8FW46BDJKOPU6ESqokHjB0T0Nc1J0Ke/hE872mPKjf9DqPyGpMbMtB egq+bXwUtOTIjV1RsaA21xi/q/KIVXdvCJgbI1O7B5jrDs25W3hGBtfDHCmZ79EmEQyU JBqQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=SE6fA2idjLIZRf601bVOTNV7dILKGQcrW7n3pawq5Fg=; fh=g4yJ4CHLEunjYIz5Aqs3ZYLGqqK7UTlLlY0tT2v0xNQ=; b=gSZ/TkTNZnPKhjGPQwfyWefhkQ0WR/ZMPI1+Exp/2VCQZ7TgjPBz1bKGEZLNGm/sZz iSiwGsE2lU+rLra98pzaSJRwhBwxp6zAtz7I5ZLrnhhe+oTSl5c8jEOdkvvrk/Lubmhe IJin9Nw67uG0EiiCsRmKqi+RPKE85fRPNnQi3AG+PIXqyGGGBlcWuZZDelVdkVrNktGX M/SifFBncf8bYf/ANidNoQLmLPMkLKKKuw19zQzdWGCVq8BUEancseNm7h8+ZDi06fku 61VGOZ6Df6ec92gn1GYUbxEkd/rf+8g59yGF+CDOdYvhYU6ZUi2ygwJv+PfAz4E0ZZsn 17Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=YL1IYvbH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c7-20020a170902d48700b001b9da7af2c0si4405355plg.214.2023.09.22.08.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 08:30:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=YL1IYvbH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4EF6883CDA54; Fri, 22 Sep 2023 04:57:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233839AbjIVL44 (ORCPT + 29 others); Fri, 22 Sep 2023 07:56:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbjIVL4z (ORCPT ); Fri, 22 Sep 2023 07:56:55 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923CFFB; Fri, 22 Sep 2023 04:56:49 -0700 (PDT) Received: from lvc-arm12.ispras.local (unknown [83.149.199.126]) by mail.ispras.ru (Postfix) with ESMTPSA id 2AFB240F1DD0; Fri, 22 Sep 2023 11:56:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 2AFB240F1DD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1695383806; bh=SE6fA2idjLIZRf601bVOTNV7dILKGQcrW7n3pawq5Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YL1IYvbHC4mavQvedeRBKW1LDWAdc/HOnv/hn+8nhNRO+J/InbHmmR7FrNKMf+ypi tz0XVQJA+QhcDfMeyoU5362ClLqTb3HONeMQdWb5TvU/UKNCFZo0tvDvNW7JMe17bC 7DPdpS3S6noddRHESh1waEiX+p/OvxD6dit0WlPA= From: Katya Orlova To: Andi Shyti Cc: Katya Orlova , Sylwester Nawrocki , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2] media: s3c-camif: Avoid inappropriate kfree() Date: Fri, 22 Sep 2023 14:55:06 +0300 Message-Id: <20230922115506.30024-1-e.orlova@ispras.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230903202336.qjdg6zw6otig2qdv@zenone.zhora.eu> References: MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 04:57:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777752193447884327 X-GMAIL-MSGID: 1777752193447884327 s3c_camif_register_video_node() works with video_device structure stored as a field of camif_vp, so it should not be kfreed. But there is video_device_release() on error path that do it. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: babde1c243b2 ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface") Signed-off-by: Katya Orlova --- v2: Get rid not only of video_device_release(), but of the entire "err_vd_rel" goto label, as Andi Shyti suggested. drivers/media/platform/samsung/s3c-camif/camif-capture.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/samsung/s3c-camif/camif-capture.c b/drivers/media/platform/samsung/s3c-camif/camif-capture.c index 76634d242b10..0f5b3845d7b9 100644 --- a/drivers/media/platform/samsung/s3c-camif/camif-capture.c +++ b/drivers/media/platform/samsung/s3c-camif/camif-capture.c @@ -1133,12 +1133,12 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx) ret = vb2_queue_init(q); if (ret) - goto err_vd_rel; + return ret; vp->pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_pads_init(&vfd->entity, 1, &vp->pad); if (ret) - goto err_vd_rel; + return ret; video_set_drvdata(vfd, vp); @@ -1171,8 +1171,6 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx) v4l2_ctrl_handler_free(&vp->ctrl_handler); err_me_cleanup: media_entity_cleanup(&vfd->entity); -err_vd_rel: - video_device_release(vfd); return ret; }