Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6809308rwi; Mon, 24 Oct 2022 06:26:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7I0mNRAxLC2oI/cdZegK2J3dMa5vlHRsi/nmgB6gf8QBCImxJqrLRbSKpFBQl+/N08cOxF X-Received: by 2002:a17:907:7607:b0:78d:66e8:c746 with SMTP id jx7-20020a170907760700b0078d66e8c746mr27898002ejc.220.1666617974771; Mon, 24 Oct 2022 06:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666617974; cv=none; d=google.com; s=arc-20160816; b=rCQ0lAnrIPal1GmzMLCqje43YNYemy6qNl4VwIdmXyxDW2kTzSblfS/RPcHBrIXD6F EfmxqBuab5tWKcAlHi7+QhIbQCwyGsjD8Njp6UBVcaEcJYW3MFo/i7ZpiuTjbAxTVaQc UWkoWcFEeXvT/lcwMcZVAXzAOk1lA8zYI0vuP85vBB+iGOL3diZDYp2TXtFY2KCJAudo WD4sptLrWB7xcnIdKGjyqCAr3wY77QoZu+4LYp2zRnTBKwvpcFWEjTia8EVMXas46+c9 pkqLtiXlZBcCTYQ6L7+vQUYHTm1kJOQcRQ5nCTd9cOWlBquOKOEDzTajkHzTct5DbUR0 iWmg== 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=eT7AKhV/eKbP7TWAck7ef5AWTXgqNF/c1Tqz3e/zqt0=; b=PV6LBklUGlFLFoQCmllCLn60/IvhGy5eBupF9yCgZ0aBdz27dPNL1AsfMZwK2L7nwi J9nb1EEsUCJxoyF3dn3M6OHUjORjYovnd9F10Dy8pm7ypkUnfR9PLzb3THqSH7PDje6t MN5XWrngDJceTSVhIm9s2bsTIXd+HEi0Y5SsG00glHNMxBVm/intnt5NI6I/nrz9ca5t HHRrFhjPGLnP9RsApbY4KhWpw8QjNkRa4F6QkDsZ3xG4JmKmYsLPx6d8Bk1ZH8Uv/c5/ CFdG/v/LtU+H1y1EXtb6ilLLwzS56hfuMfTUVcJTLHbcqTuyvATDSs3mjtUR38hLDMGK oLtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OnWiXnNU; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a1709066aca00b0078db8fe2834si25411688ejs.245.2022.10.24.06.25.48; Mon, 24 Oct 2022 06:26:14 -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=OnWiXnNU; 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 S232930AbiJXMMI (ORCPT + 99 others); Mon, 24 Oct 2022 08:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232837AbiJXMLS (ORCPT ); Mon, 24 Oct 2022 08:11:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75E88048D; Mon, 24 Oct 2022 04:53:52 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E1A61612CF; Mon, 24 Oct 2022 11:52:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE6C0C433C1; Mon, 24 Oct 2022 11:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612368; bh=t+w86/SimSzC1gn5+ybDuSGrr7/NcvbL9r66isdT9nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OnWiXnNUj7DiIQ7gebxdSUyW3AuZ15gIMXcZCXbi9qoePr2Bn8ws1BDAwSqTtQCb3 flgb+M/PGU1XvPsEChRN0uSL0OrB0i19LkUa3vhmpn/AIrTjOBXG1klVmFexXUeZXg YMpIjzoDee4gyVMadvn8EW6qXc+H+rOMpOVt6Qzw= 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 4.14 141/210] fsi: core: Check error number after calling ida_simple_get Date: Mon, 24 Oct 2022 13:30:58 +0200 Message-Id: <20221024113001.558562863@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 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 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 8feca59c1f6b..392efc2a4b8c 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -821,6 +821,9 @@ int fsi_master_register(struct fsi_master *master) return -EINVAL; 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); rc = device_register(&master->dev); -- 2.35.1