From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 3482EC56202 for ; Thu, 26 Nov 2020 01:18:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC74A21534 for ; Thu, 26 Nov 2020 01:18:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730929AbgKZBRx (ORCPT ); Wed, 25 Nov 2020 20:17:53 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8588 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728995AbgKZBRw (ORCPT ); Wed, 25 Nov 2020 20:17:52 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4ChKcM3svwzLvWy; Thu, 26 Nov 2020 09:17:23 +0800 (CST) Received: from [10.174.177.149] (10.174.177.149) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Thu, 26 Nov 2020 09:17:46 +0800 Subject: Re: [PATCH] fpga: dfl: add missing platform_device_put in build_info_create_dev To: "Wu, Hao" , Tom Rix , Moritz Fischer CC: "linux-fpga@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20201125065030.154074-1-miaoqinglang@huawei.com> From: Qinglang Miao Message-ID: Date: Thu, 26 Nov 2020 09:17:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.149] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ÔÚ 2020/11/25 18:06, Wu, Hao дµÀ: >> Subject: [PATCH] fpga: dfl: add missing platform_device_put in >> build_info_create_dev >> >> platform_device_put is missing when it fails to set fdev->id. Set >> a temp value to do sanity check. > > will this case be covered already by build_info_free()? > > Hao Yes, you're right Hao. build_info_create_dev is performed in parse_feature_list which follows build_info_free. So please ignore this patch. Thanks! > >> >> Fixes: 543be3d8c999 ("fpga: add device feature list support") >> Reported-by: Hulk Robot >> Signed-off-by: Qinglang Miao >> --- >> 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); >> >> -- >> 2.23.0 > > . >