Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp292684pxy; Thu, 22 Apr 2021 02:13:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkvshglHm27uLVwnjVvNo3SnErdcaM+IYLwV83/UGoTEh1RRmW5ZqdyMpFZc+Rrgpqa0sc X-Received: by 2002:a17:902:a406:b029:e6:78c4:71c8 with SMTP id p6-20020a170902a406b02900e678c471c8mr2471742plq.17.1619082787132; Thu, 22 Apr 2021 02:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619082787; cv=none; d=google.com; s=arc-20160816; b=EAOuwrswuLbFclOe1MAYslqzFZ4df6TWUElPn14KLjWx4eDu9kkCHT7w/7srvH57/5 OQmEA2SY3SrSrcTXZymj5hKZmlidg5L6HafctpPWpHJKTOcIcuCbVyTtKl9csD3Z5aU5 L7NITCrZpIhm6uAc3XsL0xxtAekqgvinyEUz0kczhTUqMCq5bx5qDMzPp29Bdj5qAvQI uno2V40Cz5yQUXRxYl3eedwQwQtIf1XVM6UTch4ozNhTLnva/JFOp9VXYBYdoW8cglSA ru7rfzTWdmKkWcUdGo8PDBuAnN+4nsbVQDgN+pSYAbURp0f9TVdAkjxedP5XMBz6YYQ4 9jlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=GfNIYgwxlG1PoarHwy8HPbhqCeRGTR5cailtNG4Fve8=; b=dcvJNi+FWEEtzsIsdovdYYMq2g1KbFiMm6+G4XDW5GUxhjrdymSY/o5eN0+gKqS+Jp gOdwtaECqmPrqRSM/S/VV9gD+ODO9di6zVO412q+GGMF8CGNJcoccpf14XCHXbPWDXm+ JVm+nquCYsUHZKdkEbHWVsH/w16gYyKYwLOSOGpgp8IeFaMGLAeIlCIQGfZydQSJKkL/ IhPrMg0y3IV/lDLnucubjqeC8LeOP9qooyX/FdQdCNfs7c3u6DWT+nkuKYLi1HzDsidY qjTgBlH19RMAJOn+27yIHnnCUoNC5Z9rN3aAC/+YhWKtMfHrTks0xQEvCfywSgmSa/Jz /yww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=KblNUNp8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si2473703plc.411.2021.04.22.02.12.55; Thu, 22 Apr 2021 02:13:07 -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; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=KblNUNp8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235004AbhDVJMy (ORCPT + 99 others); Thu, 22 Apr 2021 05:12:54 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:51358 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230285AbhDVJMx (ORCPT ); Thu, 22 Apr 2021 05:12:53 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13M999Hp015712; Thu, 22 Apr 2021 09:11:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=GfNIYgwxlG1PoarHwy8HPbhqCeRGTR5cailtNG4Fve8=; b=KblNUNp88rGkN6Jqx/V0A0KyHxdzRoEvtWBjhXjwBD565Nq6noruJHkIq7VGCGwRxOsd lydWnyYjK9JGgCK8i/J4GQaw377ds8TuO3dpukqJ+LvakCp4CgIF8KsA6AzZtK71UWPq DEXmoad5mbyWkgGuLb7MdQOvagtl4CbgrT4Gxzt6O2Q33Hav9BStRTCyz2b7euCPDxOg fmSbvMCaX9Sfvu2pdhOUeNMTqZ7m2EDvHS2UFirVySalrMLWjSJHzTinMovqpT6BKsZX kC9ulOgtXojTr6/qhxiwwAXCj7r39Jt1AmbCHc17yDRRz505cT/H8xAaRpRYpZFSfa2h Iw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 37yqmnmsbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Apr 2021 09:11:57 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 13M9Aueo151761; Thu, 22 Apr 2021 09:11:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by userp3030.oracle.com with ESMTP id 3809m1x2g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Apr 2021 09:11:57 +0000 Received: from userp3030.oracle.com (userp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 13M9Buj5154989; Thu, 22 Apr 2021 09:11:56 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 3809m1x2fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Apr 2021 09:11:56 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 13M9Bqkw028273; Thu, 22 Apr 2021 09:11:52 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 22 Apr 2021 09:11:52 +0000 Date: Thu, 22 Apr 2021 12:11:44 +0300 From: Dan Carpenter To: Joel Stanley Cc: Andrew Jeffery , "Chia-Wei, Wang" , Jae Hyun Yoo , John Wang , Brad Bishop , Patrick Venture , Benjamin Fair , Greg Kroah-Hartman , Robert Lippert , linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] soc: aspeed: fix a ternary sign expansion bug Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-ORIG-GUID: kJLzve4nSPiUlwZkC1ctP0MZQjv0yXzk X-Proofpoint-GUID: kJLzve4nSPiUlwZkC1ctP0MZQjv0yXzk X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9961 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 clxscore=1011 lowpriorityscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104220077 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The intent here was to return negative error codes but it actually returns positive values. The problem is that type promotion with ternary operations is quite complicated. "ret" is an int. "copied" is a u32. And the snoop_file_read() function returns long. What happens is that "ret" is cast to u32 and becomes positive then it's cast to long and it's still positive. Fix this by removing the ternary so that "ret" is type promoted directly to long. Fixes: 3772e5da4454 ("drivers/misc: Aspeed LPC snoop output using misc chardev") Signed-off-by: Dan Carpenter --- drivers/soc/aspeed/aspeed-lpc-snoop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c index 210455efb321..eceeaf8dfbeb 100644 --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c @@ -94,8 +94,10 @@ static ssize_t snoop_file_read(struct file *file, char __user *buffer, return -EINTR; } ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); + if (ret) + return ret; - return ret ? ret : copied; + return copied; } static __poll_t snoop_file_poll(struct file *file, -- 2.30.2