From patchwork Wed Nov 25 06:50:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qinglang Miao X-Patchwork-Id: 11930439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79A80C56201 for ; Wed, 25 Nov 2020 06:46:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4003C2067D for ; Wed, 25 Nov 2020 06:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbgKYGqU (ORCPT ); Wed, 25 Nov 2020 01:46:20 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:8401 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbgKYGqT (ORCPT ); Wed, 25 Nov 2020 01:46:19 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Cgrxx2fxVz73CW; Wed, 25 Nov 2020 14:45:57 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 25 Nov 2020 14:46:07 +0800 From: Qinglang Miao To: Wu Hao , Tom Rix , Moritz Fischer CC: , , "Qinglang Miao" Subject: [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev Date: Wed, 25 Nov 2020 14:50:30 +0800 Message-ID: <20201125065030.154074-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org platform_device_put is missing when it fails to set fdev->id. Set a temp value to do sanity check. Fixes: 543be3d8c999 ("fpga: add device feature list support") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao Reported-by: kernel test robot --- drivers/fpga/dfl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c index b450870b7..8958f0860 100644 --- a/drivers/fpga/dfl.c +++ b/drivers/fpga/dfl.c @@ -877,10 +877,13 @@ build_info_create_dev(struct build_feature_devs_info *binfo, INIT_LIST_HEAD(&binfo->sub_features); - fdev->id = dfl_id_alloc(type, &fdev->dev); - if (fdev->id < 0) - return fdev->id; + int tmp_id = dfl_id_alloc(type, &fdev->dev); + if (tmp_id < 0) { + platform_device_put(fdev); + return tmp_id; + } + fdev->id = tmp_id; fdev->dev.parent = &binfo->cdev->region->dev; fdev->dev.devt = dfl_get_devt(dfl_devs[type].devt_type, fdev->id);