From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA3E46FA0 for ; Mon, 16 Jan 2023 16:43:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F781C433EF; Mon, 16 Jan 2023 16:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673887407; bh=0kXwMbSk4TsFadYGIKLEPb7evQzpT9GyIsXDrwmABvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XxshulXlKoVB/nZ3omV12KhHu6jc2yzDk9bBO7dh4p2psh8GYP9zuyHX6XBut4qgx 1qoAoERrhBkyRsl4PaYEdWBonR4M8kvdWdHf5LyVIwwpzE/yLUwau7lLRDCyI4a54x FvTCXfQdRZu89lsl2Osz1G9QYUrV9gzZW6L3QsS0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yang Yingliang , Hans Verkuil , Sasha Levin Subject: [PATCH 4.19 108/521] media: solo6x10: fix possible memory leak in solo_sysfs_init() Date: Mon, 16 Jan 2023 16:46:10 +0100 Message-Id: <20230116154852.090471275@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154847.246743274@linuxfoundation.org> References: <20230116154847.246743274@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yang Yingliang [ Upstream commit 7f5866dd96d95b74e439f6ee17b8abd8195179fb ] If device_register() returns error in solo_sysfs_init(), the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(). Fixes: dcae5dacbce5 ("[media] solo6x10: sync to latest code from Bluecherry's git repo") Signed-off-by: Yang Yingliang Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/pci/solo6x10/solo6x10-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c index 19ffd2ed3cc7..d3bca099b78b 100644 --- a/drivers/media/pci/solo6x10/solo6x10-core.c +++ b/drivers/media/pci/solo6x10/solo6x10-core.c @@ -429,6 +429,7 @@ static int solo_sysfs_init(struct solo_dev *solo_dev) solo_dev->nr_chans); if (device_register(dev)) { + put_device(dev); dev->parent = NULL; return -ENOMEM; } -- 2.35.1