Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3586919pxb; Mon, 24 Jan 2022 12:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaeAMchq/BHOuDQR0Lu19wa9DPrI+Aan3RaThnIwoXHFPO1XPGxPqPrUBRimOXo4OF+bHt X-Received: by 2002:a05:6a00:2442:b0:4c5:75b4:d53e with SMTP id d2-20020a056a00244200b004c575b4d53emr15187379pfj.49.1643057660793; Mon, 24 Jan 2022 12:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057660; cv=none; d=google.com; s=arc-20160816; b=XoV+YvnIeKxKkVum1OcTp1nX7CGuwepKE8lKLohGbAHLXbd3nrYaFGG8P1owcvcc9X yrv6EvYw12hnIarIvnR06XtAmtDNrQA5EwdcLpU9uNxEG+DpUSZ6RlbRLQYBZaqVOdTp F7bBVhGpmKdcqIS24YyxbWCs6hwrM4YNJBUcrFBr8YQZuETagi9hWyRmrROPWpsgFrbJ c4AGg9xhvwO5o6duRyjIEANWGBwVILwnN3U3f6/qyj3uUgnTT1PcOtgkZFY7gmoVPaHt ioAci4e6xlggMP0CbmLk3yb0ugJvvI9GrGy6MkWTOWqNY8SLjEAhSeLuiYpkxY4b7bax o6lg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Em/Q9xKHTbHCBKo9HpxP9Dq3RDfKmz17GrNqa8eLnfw=; b=sKvpKR6yI5od9bUMSLa5OmDWAocQ9tXTt7dzNv90JiEn0JGdTtBAAx3pGFVjDaop7z KNxKL2weO1dNmxgs+njJbfkAnmyIt7nyfb4gi9Rv52I04vcdd0jzXJLQZO17bm2t6LDq J3NoW/EEWnYPq0in5cBl5s7manDDxzy9B4INd3PXP0TzD9kly74TBPAsuvlaGJM/l0I+ U0vlJjEdOPH5W1MPq1mHB1kfrjkssAhKKCwh3Teo2GQ6CSwPomKJpdNNlt9ti95D0QdJ FgvQJp1bHwPa7wR9UhmkeB9nM2U3ozMFDrX2d+G936o2k+HxF5/aZhdzobp6650/RodT 3l/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IOqHTpz7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si320573pjw.154.2022.01.24.12.54.08; Mon, 24 Jan 2022 12:54:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IOqHTpz7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380094AbiAXUPi (ORCPT + 99 others); Mon, 24 Jan 2022 15:15:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358413AbiAXTzI (ORCPT ); Mon, 24 Jan 2022 14:55:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C036C0418B1; Mon, 24 Jan 2022 11:27:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 05889B81243; Mon, 24 Jan 2022 19:27:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33E35C340E7; Mon, 24 Jan 2022 19:27:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052437; bh=fntRpshkPH1kBf19IZiQRtlhXjIeJ4hCEiSlfehiMwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOqHTpz7uQp39FFBwlM+7FHzveyW3T7IZ82Uzf3+bFIzRKQ0ZQ67oVietWCnM0Iv1 eTdU+0AR5xHwL2TYgacdTENGOuPw9q5qoTtRGdmvj15kd8CYvJ/V7EE0DjQ0NW5BmL 84H9mPijXCfacmKhlP4O9XtiWWXMEmfxGWIAdVlM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 057/320] media: si470x-i2c: fix possible memory leak in si470x_i2c_probe() Date: Mon, 24 Jan 2022 19:40:41 +0100 Message-Id: <20220124183955.677433044@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit ef054e345ed8c79ce1121a3599b5a2dfd78e57a0 ] n the 'radio->hdl.error' error handling, ctrl handler allocated by v4l2_ctrl_new_std() does not released, and caused memory leak as follows: unreferenced object 0xffff888033d54200 (size 256): comm "i2c-si470x-19", pid 909, jiffies 4294914203 (age 8.072s) hex dump (first 32 bytes): e8 69 11 03 80 88 ff ff 00 46 d5 33 80 88 ff ff .i.......F.3.... 10 42 d5 33 80 88 ff ff 10 42 d5 33 80 88 ff ff .B.3.....B.3.... backtrace: [<00000000086bd4ed>] __kmalloc_node+0x1eb/0x360 [<00000000bdb68871>] kvmalloc_node+0x66/0x120 [<00000000fac74e4c>] v4l2_ctrl_new+0x7b9/0x1c60 [videodev] [<00000000693bf940>] v4l2_ctrl_new_std+0x19b/0x270 [videodev] [<00000000c0cb91bc>] si470x_i2c_probe+0x2d3/0x9a0 [radio_si470x_i2c] [<0000000056a6f01f>] i2c_device_probe+0x4d8/0xbe0 Fix the error handling path to avoid memory leak. Reported-by: Hulk Robot Fixes: 8c081b6f9a9b ("media: radio: Critical v4l2 registration...") Signed-off-by: Yang Yingliang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/radio/si470x/radio-si470x-i2c.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c index a972c0705ac79..76d39e2e87706 100644 --- a/drivers/media/radio/si470x/radio-si470x-i2c.c +++ b/drivers/media/radio/si470x/radio-si470x-i2c.c @@ -368,7 +368,7 @@ static int si470x_i2c_probe(struct i2c_client *client) if (radio->hdl.error) { retval = radio->hdl.error; dev_err(&client->dev, "couldn't register control\n"); - goto err_dev; + goto err_all; } /* video device initialization */ @@ -463,7 +463,6 @@ static int si470x_i2c_probe(struct i2c_client *client) return 0; err_all: v4l2_ctrl_handler_free(&radio->hdl); -err_dev: v4l2_device_unregister(&radio->v4l2_dev); err_initial: return retval; -- 2.34.1