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 E45BE1863 for ; Wed, 28 Dec 2022 15:38:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D51C433D2; Wed, 28 Dec 2022 15:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672241923; bh=J5Od7YALa/hq23/+T6cu9swVfU4oJMnR0f8eH49DHrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gVYRimowZ/KqPfAupEMz/VMNH8kG3Ck5tQg3PXlc4JuetbnhUTy9CNHJNqR43Rzju pdK1iA+GxMIm80QYDSZvQ5xyF3i4qzfok5MOseIViHIdfT8FMY+mP1fHpMjLiPjyw9 Dg49mcPKcBrj7XlguI7uVDgP+KbFiaC+RQa4ED5I= 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 6.0 0344/1073] media: solo6x10: fix possible memory leak in solo_sysfs_init() Date: Wed, 28 Dec 2022 15:32:12 +0100 Message-Id: <20221228144337.350095918@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144328.162723588@linuxfoundation.org> References: <20221228144328.162723588@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 4a546eeefe38..6d87fbb0ee04 100644 --- a/drivers/media/pci/solo6x10/solo6x10-core.c +++ b/drivers/media/pci/solo6x10/solo6x10-core.c @@ -420,6 +420,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