From patchwork Wed Oct 19 08:31:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5284 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp280930wrs; Wed, 19 Oct 2022 05:01:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HKFvRtUWukXbhgjfDtKqN1ayHk76/QnSpoSi07r0n6BozVlfzXZQQTfiJv28h01OJGDkw X-Received: by 2002:a17:907:2c75:b0:78d:c201:e9aa with SMTP id ib21-20020a1709072c7500b0078dc201e9aamr6422790ejc.235.1666180888090; Wed, 19 Oct 2022 05:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666180888; cv=none; d=google.com; s=arc-20160816; b=oO+ENHksfy2iqKNZ/CHaVGHYaIqpHVXVaZnSBuggUE9ObxPyhD8I0S4cN6kvWrZeP1 7UcacVoZ8XsrOoqsVDqqsNbZ8ZppL9nayym3Y3AXo5TSqL6L/aBuWnYAECiwg4S2NlQJ H8y2hUI93s22qoRNMsuLN434syqtGeI9CqWQnv5FkYa2dM3hRkrUR4A67xAHr3mQebN3 ThE3bp1/7F4L6eVL2bIz3+jK8MgCttMnD031uVNMrvdLIQhiOisYTZDNRLAWky3UXoP9 Rrs0k/OokDe7AXVjo0BCIe396/Iv51cVzktSRjrBx5a2E7MHiUEdHgMHwdA1L89F8y7w Ivqg== 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=2gns+FEdS4MRDGVMHTHPbHNp/HxSEF7fIZwKgvc6t3o=; b=SC2yjDkSsvviQfgdN/tYrNjHd4DmAotQLTxrX3/qpeDhfvozTKwUalR7p9WryDs9AF 8NZPXMXB0TqT/MqgcKZVYG9ljdd1o7ZLIVl4cnjMMx0rongJ6+tY5cDaXsfyEl7xcemD rwlUmPvCHTjlJbguuAdzjLW6UHh/k91vDVsDWusc7IC+5D6FrQDZ9Y6kWbGbofcRlwyJ bwNyjuHazK40Nl9wJ6Gkxs+j8HwHE5lwW8Wu2wz8Q/sQTUn6NbklMzonK5mgKARDsR8b VYKnzNF82IOIi/P3fO/Dvs5pwDSRvBAqtFwxQSDw7H+b5jdsMZ9SKdfcrM5+FG2INhAL JlEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sNT3XQMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a170906354a00b007891fd9179bsi11787374eja.150.2022.10.19.05.00.59; Wed, 19 Oct 2022 05:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sNT3XQMg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231837AbiJSL4E (ORCPT + 99 others); Wed, 19 Oct 2022 07:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232624AbiJSLyy (ORCPT ); Wed, 19 Oct 2022 07:54:54 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAE8BE51C; Wed, 19 Oct 2022 04:34:13 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id D30A6CE2157; Wed, 19 Oct 2022 09:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B50C4C433C1; Wed, 19 Oct 2022 09:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170220; bh=1OAwvSabGh6LnKItuicwtRw9I08Q/Qc3Yz5P8kejiIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sNT3XQMgoTyxVBCMHZf/jf5RHQ+SvhM/NLbITtdDL/txxfriWRt0HkIQsL3h4mFOp EEqwgmIxHHydCYJnLYnFT4Bbvh8wQcigyVvIXdgsG7Ph0/mtXcF2++fVinaSEnkmGt ussTs7x1W8ncngz2BURXn6bAN1X8GQVRvfOI3nZw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Eddie James , Joel Stanley , Sasha Levin Subject: [PATCH 6.0 573/862] fsi: core: Check error number after calling ida_simple_get Date: Wed, 19 Oct 2022 10:31:00 +0200 Message-Id: <20221019083315.296999903@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747117290983692504?= X-GMAIL-MSGID: =?utf-8?q?1747117290983692504?= From: Jiasheng Jiang [ Upstream commit 35af9fb49bc5c6d61ef70b501c3a56fe161cce3e ] If allocation fails, the ida_simple_get() will return error number. So master->idx could be error number and be used in dev_set_name(). Therefore, it should be better to check it and return error if fails, like the ida_simple_get() in __fsi_get_new_minor(). Fixes: 09aecfab93b8 ("drivers/fsi: Add fsi master definition") Signed-off-by: Jiasheng Jiang Reviewed-by: Eddie James Link: https://lore.kernel.org/r/20220111073411.614138-1-jiasheng@iscas.ac.cn Signed-off-by: Joel Stanley Signed-off-by: Sasha Levin --- drivers/fsi/fsi-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 3a7b78e36701..5858e6339a10 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1314,6 +1314,9 @@ int fsi_master_register(struct fsi_master *master) mutex_init(&master->scan_lock); master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL); + if (master->idx < 0) + return master->idx; + dev_set_name(&master->dev, "fsi%d", master->idx); master->dev.class = &fsi_master_class;