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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, 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 B833FC433B4 for ; Sat, 24 Apr 2021 07:01:03 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DDA66054E for ; Sat, 24 Apr 2021 07:01:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DDA66054E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IIRu3wXeVG95uA0/ZPDUFUm9tuOZ1nlx1faT2CTRkTI=; b=JlBzsRNerq99tL7KTCTWvFIaJ rE/mSKrlif0gSWCw0wSyho8FPYho0VVggVzphcgp/vnXuHiKPnFPT7ccozkNkPV3e4tE6qRcl2b1Z u2ZykeCqoO9ef8oGB/AworIttMJG8wWQRtNLWzjUejhPLTEJxCJ7yZfEBcDlIp1mR4kVanYw5Wk9e 7w4Q6r9LMrp1LyHDsUhW9aCl/yt4wgrgEwwRu0jdVCvRFajhRiKN2w3AeSucHHf7rdB6MoqwsEqMJ Wsc9wN8Y+BPBrUH8d2MAsbV+xESH4296+YwRV6yriRJ5dqg603eZ/tUAqrni4wZW8mYyck3UKRbA+ /g5IVaiDQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1laCFh-003CFJ-PI; Sat, 24 Apr 2021 06:58:53 +0000 Received: from bombadil.infradead.org ([198.137.202.133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1laC4k-003BAl-3b for linux-arm-kernel@desiato.infradead.org; Sat, 24 Apr 2021 06:47:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=B2e0yO5JEDbjpt9UVoxx75p29kZv7siwpuysnfs6zd0=; b=nvXA/dgLbBBXsno1fzLcG9hmB/ KOaqs3zyle98OP6mWDjtQNB9hn7V0B/ulOfIaSiNTPK26CNXfJa/hL9iOKZMj2s/Foldx0hVeii+l y4Z78HCJgrJ+T2vEtYCzbadKUCGeiG/YockLdoK/2CnA5EmrVy5b3dmPbUo5W/zkUxhBl7zovgPdU zRU7vAdX4slnTNZ+6zNyAgBlFNFP9imgjZELgAsWaIvZ6YRMb7kdfX2DXTfu5/zJ1c1Apa26b2TIW zeZQLy3n7XSc/vvNyWcQP7jMksP/8DSQxUt7bdgMdZM4R6SLR73AHXTlcP6URmhFv86BX5j2gOTNc 7B4vf6xg==; Received: from userp2130.oracle.com ([156.151.31.86]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1laC4h-00EsHQ-Bn for linux-arm-kernel@lists.infradead.org; Sat, 24 Apr 2021 06:47:32 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13O6Ou7e083276; Sat, 24 Apr 2021 06:43:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=B2e0yO5JEDbjpt9UVoxx75p29kZv7siwpuysnfs6zd0=; b=ZVALcXpwgYy2uwAYcSB9lBXh9F2N79cE9+O5Gd1IE7ytBiH89/dQNy1d1cZjFg8C2wih 5nM6PIeaTPU41Ev0jgvyfiMYal8nXzDnxX/d8ptnTcLiYgQyu1z+//6BM1OEK8bYbMlP 4WoMrcgxekKZUr0QtRwaQixT/d15+uYkItQzwx4UxGw7YtWCX6XSuWObZhn/zGDFOPZi V3xMdfZsx0hRLKr9YVi/Q+LKfLTNoLcZlTE6nZWYOIVln2E/LRDYVBFWzB46U6rSqx57 VWvWUUaPkbb9MjFGa9PUDPmXwLIkN+gYsW7NAIUF4LMU1eHhy67wwxmpQXbuEuseI7fk xQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 384ars04ga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Apr 2021 06:43:18 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13O6PZJj164989; Sat, 24 Apr 2021 06:43:17 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3020.oracle.com with ESMTP id 384b5164m8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Apr 2021 06:43:17 +0000 Received: from aserp3020.oracle.com (aserp3020.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 13O6hHsP019326; Sat, 24 Apr 2021 06:43:17 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 384b5164kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 24 Apr 2021 06:43:17 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 13O6hDjr030484; Sat, 24 Apr 2021 06:43:16 GMT Received: from kadam (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 23 Apr 2021 23:43:13 -0700 Date: Sat, 24 Apr 2021 09:43:07 +0300 From: Dan Carpenter To: Sudeep Holla Cc: Cristian Marussi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] firmware: arm_scpi: prevent ternary sign expansion bug Message-ID: <20210424064307.GV1959@kadam> References: <20210422174631.aruiqqqx3szboqdp@bogus> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210422174631.aruiqqqx3szboqdp@bogus> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-ORIG-GUID: UjpaBYuHQzR7qtW6xmIOkAwv1T9BSn8T X-Proofpoint-GUID: UjpaBYuHQzR7qtW6xmIOkAwv1T9BSn8T X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9963 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 clxscore=1015 spamscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104240045 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_234731_579922_B2589D42 X-CRM114-Status: GOOD ( 30.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 22, 2021 at 06:46:31PM +0100, Sudeep Holla wrote: > (dropping Tixy as I am sure it will bounce, he left/retired from Linaro > long back) > > On Thu, Apr 22, 2021 at 12:02:29PM +0300, Dan Carpenter wrote: > > How type promotion works in ternary expressions is a bit tricky. > > The problem is that scpi_clk_get_val() returns longs, "ret" is a int > > which holds a negative error code, and le32_to_cpu() is an unsigned int. > > Agreed. > > > We want the negative error code to be cast to a negative long. But > > because le32_to_cpu() is an u32 then "ret" is type promoted to u32 and > > becomes a high positive and then it is promoted to long and it is still > > a high positive value. > > > > Thanks a lot for finding and fixing the bug! > > > Fix this by getting rid of the ternary. > > > > Fixes: 8cb7cf56c9fe ("firmware: add support for ARM System Control and Power Interface(SCPI) protocol") > > Signed-off-by: Dan Carpenter > > --- > > drivers/firmware/arm_scpi.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c > > index d0dee37ad522..3bf61854121d 100644 > > --- a/drivers/firmware/arm_scpi.c > > +++ b/drivers/firmware/arm_scpi.c > > @@ -552,8 +552,10 @@ static unsigned long scpi_clk_get_val(u16 clk_id) > > > > ret = scpi_send_message(CMD_GET_CLOCK_VALUE, &le_clk_id, > > sizeof(le_clk_id), &rate, sizeof(rate)); > > + if (ret) > > + return ret; > > This could be still an issue, ideally I would prefer to pass the return > value via argument pointer and always return success/failure as return > value. Can't remember any reason for this. Since this is old interface > with limited platform to test, I think returning 0 as clock rate on error > should be fine as Cristain suggested. If you agree with that, I can > fix up when applying. > That sounds great. Thanks. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel