Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4338970pxb; Tue, 5 Oct 2021 00:30:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2q/WNZV20WZ3nyZvuSrmcrmt9lp7TxcNHdNarEONCeM5rGASuC57WoK7GMezThLIAQp+Y X-Received: by 2002:a17:906:b00a:: with SMTP id v10mr23672766ejy.158.1633419047840; Tue, 05 Oct 2021 00:30:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633419047; cv=none; d=google.com; s=arc-20160816; b=cLbBpG89RJmJ9L3bNoD/Yxg2J+LBIxfPAlkCTn497z8+szb46VOndBkkPL07EQGQ8T M+WWoXhTPzEI2GD5xxPMDKpOauXVYJPXwIj8nv9ccHpdIVZt3o0gq5bRULJuc1V0qsul Eu+C2KnzmA66ifpof7T7vDCftkbLt2EL7Db1bCJ3g3btpp99dJKJ1HXfjq0mJXP48pj4 BNtWc4tWICcwPzEBa9LbXSSeVsyK0dYUpwZneuVZ4ym7d3oycqpH1k8y8Cw1NgjmL3Z6 1y7RXTh4gdrShc0aJvQbc6KMQAfhQA1P5j+sIdyt2po+ckI6/5/Cj0l+CZ9am+CeYb2s VZZA== 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 :message-id:date:subject:cc:to:from; bh=2iUigLg54utcBFy1K1YhL3EJrZBRsr9WtOPb/ud2Gpg=; b=hMwtEXZedJdRTJEOyr8B7+cjn3ixmCF064s1kYeTNa/wSJv/9euPTZtQlMiPhxV9Q2 H+a2VmZK5KAcZ5mXJ2Ih8DBDlteIdWHtC7uCeRNp3xWV1uEkGgy9oIlNodbkTkgT9fmG Ti0mqzhtx68kigWzLoBZtQAs4uVP3V04AO7A5L9wEZRqQkc8pQGilah/HDF74uQQkRcZ B+nGakILiva+uTTjFfkUpabqE0l4l6Llsi/JkENnltJMEeA4ugXJXlucozri6CKA0VQB yCzcgTaEB7vabFFTlkP/CVLtWXZbHbjwvkOoLqXLcVpVbw5EBi8C2u7U9RYYw4rxuEv5 5W8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo9si21374905ejb.690.2021.10.05.00.30.23; Tue, 05 Oct 2021 00:30:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232788AbhJEH22 (ORCPT + 99 others); Tue, 5 Oct 2021 03:28:28 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3913 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232511AbhJEH21 (ORCPT ); Tue, 5 Oct 2021 03:28:27 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HNpwm3rRXz67XcG; Tue, 5 Oct 2021 15:23:52 +0800 (CST) Received: from roberto-ThinkStation-P620.huawei.com (10.204.63.22) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 5 Oct 2021 09:26:35 +0200 From: Roberto Sassu To: , , CC: , , Roberto Sassu Subject: [PATCH] s390: Fix strrchr() implementation Date: Tue, 5 Oct 2021 09:26:21 +0200 Message-ID: <20211005072621.53500-1-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.204.63.22] X-ClientProxiedBy: lhreml754-chm.china.huawei.com (10.201.108.204) To fraeml714-chm.china.huawei.com (10.206.15.33) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Access the string at len - 1 instead of len. Signed-off-by: Roberto Sassu --- arch/s390/lib/string.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/s390/lib/string.c b/arch/s390/lib/string.c index cfcdf76d6a95..162a391788ad 100644 --- a/arch/s390/lib/string.c +++ b/arch/s390/lib/string.c @@ -261,12 +261,12 @@ char *strrchr(const char *s, int c) { size_t len = __strend(s) - s; - if (len) - do { - if (s[len] == (char) c) - return (char *) s + len; - } while (--len > 0); - return NULL; + if (len) + do { + if (s[len - 1] == (char) c) + return (char *) s + len - 1; + } while (--len > 0); + return NULL; } EXPORT_SYMBOL(strrchr); #endif -- 2.32.0