From patchwork Mon Oct 24 11:31:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp431038wru; Mon, 24 Oct 2022 05:42:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62tZKCabaJBNmYD10XZRkjH22LAVvqMOyvDYPbiZFHuNuenPSuZoWS7YWZnm1xo/MJnNlB X-Received: by 2002:a63:ed0a:0:b0:442:2514:95f5 with SMTP id d10-20020a63ed0a000000b00442251495f5mr28316773pgi.402.1666615369080; Mon, 24 Oct 2022 05:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615369; cv=none; d=google.com; s=arc-20160816; b=UWEmXqm50nebwzvXMN0+sDxK11SW/GC/zWueaBVOcbpmDW6HOZE1QosPJbDlGM5GZ0 WrT7jSLwHVe3U30S02arbGpaL9+ASNlKwqyMVqOzbfiEHtJ8nDItctka8amWe8IiN0MS A4a2kXYcjaCdhNCAbEpXh2QNdnehrbPcnljLdt0+vYACVhOy7JIyBn+SvFAmFNKb7/51 x5Yd13cWYj8WylbVEDwsrQ0WPi57XGlRksglYuqw7igM1xXY1agJxTzAdzyE/t2HvXxj Q/VMtEFV1kmG+n40BYq9l2OVH73lq1yTltKwhOpNDwr22c96yeAtoCVbuH7Gdfe5IDwb 1LWg== 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=K0s6mjZCp/PrlHbJmWIyOUVAXbxl/eHpEMYWV0hvlrQ=; b=hWFl2KGmx+36FEATqN18Fo+Vk1yKf2Dn6RiC7KKJ4+4BBzHDosX0TeyBwdujMPWpyx aVhVk23RZvv0pT6Bs0fBcHNIRJaAuVCeQGRZbQZBCMRxnYq6+lrOy57dy4c+DLVQV50A weOtBg5+sTgDZ8EySbOt2t2zCsK3lKYwT+eAi7DBxd+KpRWG8LVHhd2MMM+JAI/3Q8z8 4/Qq9tgWNVWjk6O4Vi8t3Nlb2W7uu7nt6Vi2B3yNgcX8F6HOMPjYjdrnfSPRsUF4D9jG YQmLNcg2YH6penyMbheXSweVnpzZHEmJQqIySIfDz3CUqc8FcF+zSYMgNJM5GFIjVKM8 9rJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=miRY9EIA; 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 t185-20020a6381c2000000b00437e609414dsi33439450pgd.563.2022.10.24.05.42.34; Mon, 24 Oct 2022 05:42:49 -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=miRY9EIA; 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 S230236AbiJXMf7 (ORCPT + 99 others); Mon, 24 Oct 2022 08:35:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234288AbiJXM3z (ORCPT ); Mon, 24 Oct 2022 08:29:55 -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 B63ED895E8; Mon, 24 Oct 2022 05:03:47 -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 14AF161257; Mon, 24 Oct 2022 12:01:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A1E4C433C1; Mon, 24 Oct 2022 12:01:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612867; bh=FJTfVOh3xOjX9DDYE/z89CAejeedv3qzSVwkojus+pE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miRY9EIAF6Pm4Z3VLGUx8ludy03ws7nHzegW3Nz9SakiO3/mgY3boR3e2GpX1Mrb3 5tqwG7jNUs7cA2aQ81JUo5rLEMyht8kpCQaTC2YDJg9hKSMc+BbhcMdV8YGyiis28N YoE9Bk7SZ7CMhnzz4i6pDxZOGlbtErEghSgEoHdo= 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.19 148/229] fsi: core: Check error number after calling ida_simple_get Date: Mon, 24 Oct 2022 13:31:07 +0200 Message-Id: <20221024113003.802441422@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747572877316265505?= X-GMAIL-MSGID: =?utf-8?q?1747572877316265505?= 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 5b4ca6142270..5133fe0a0abe 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -1279,6 +1279,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); rc = device_register(&master->dev);