Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4607178pxj; Wed, 12 May 2021 09:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoBKJSL+e5iTb4nszkjsaMcLviUX+/I43jGTB1MBEDDm7UClg+/hlsJ46g3ltoQ0JCOqfj X-Received: by 2002:aa7:c15a:: with SMTP id r26mr45110773edp.78.1620835700598; Wed, 12 May 2021 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835700; cv=none; d=google.com; s=arc-20160816; b=UcysmgZpZpDZ6FpPMe5ZR4oRl5m7sMsNNAqJybsAoMgrLD0ZvIDwp4XkgzAxlri98D wBQQYpRZhCtjVP8RqqxutlOaxYKmIlMx+DGV4k/XCyPpQjTwvRDpXj9UpnFGmWwfcYZd h52u/n0MwdY4XKX5QpoN893bQQXP217C/HDqzBWUtKZUppFJ1a/XuRuCgSziL3BnRWob IG4BMCvzFdK1G4nzgNRHWs8ie5+ZCokw3Rt0wJNSCjlO0tKQNohbabLhV+f0H+oLQ1Mp xKQ90WRGkQFkYiwzoRfg3MYiow2vGTAFHptP78ajeoZr6U4LcENq39WCZ/Iz3XNAqVGp cpIw== 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=UTKm1/x8sFJwc4Jw0/3E6VE55yqd0/3/eCv9JJowZFM=; b=zPZ9VpkKd5mKGn7/cs2Sw/oHSE0+o4FHNcqyM1YjLIjAJqtl08RgJmguAm7GZsczDp CJXkN1AQrn+f3pnIFvtK5LurrVpFyxJ215HibR7Z0UHcI7JsZBeZ4kgW8X4pXBE7vncB p1LvIZ6sc+95DBZRuZB5fxPNdIHLbX9c2AjWACaEUB5Tth0u4gCgfvlFeBK+k0Gqf3AX 7hRSgi/qcq/dc2uLY6HACtvjRdie/GpfVg8kuAo7R+l0NNbHkc2DMdNXYEW9TjA7f4eK Txvq3MA7KHDbDNkuXMj4GWBQNqcz3j1uYt8KjBO9+8CXZ17BIstQ+SLE1VdyTfB0HAyh UvBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hkK4IqUw; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si273371ejf.717.2021.05.12.09.07.55; Wed, 12 May 2021 09:08:20 -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=@linuxfoundation.org header.s=korg header.b=hkK4IqUw; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238113AbhELQEY (ORCPT + 99 others); Wed, 12 May 2021 12:04:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:40490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235561AbhELP2b (ORCPT ); Wed, 12 May 2021 11:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AC3461C26; Wed, 12 May 2021 15:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832430; bh=q1/IcQVgXlUD0gUcHUY67siCIkWUFeOim6tCP7jKEA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hkK4IqUwxmlNFkQJweTrD7WwGD54i5HLq7wramv/zknzEc7v7LJQFuxVNnnr1SRwR zTSESR9sXnHxrIJEQKMWgm99B6tNJKp3U0SXgb0NjA+Wch5QqwnWRMZ/BcZlbdiLEB ZMnRf964M8GQyuEPo4IX3nZqdcHbwJ1S/J+fl7o0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Joel Stanley , Patrick Venture , Arnd Bergmann , Sasha Levin Subject: [PATCH 5.10 276/530] soc: aspeed: fix a ternary sign expansion bug Date: Wed, 12 May 2021 16:46:26 +0200 Message-Id: <20210512144828.878822793@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 5ffa828534036348fa90fb3079ccc0972d202c4a ] 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 Signed-off-by: Joel Stanley Reviewed-by: Patrick Venture Link: https://lore.kernel.org/r/YIE90PSXsMTa2Y8n@mwanda Link: https://lore.kernel.org/r/20210423000919.1249474-1-joel@jms.id.au' Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin --- 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 dbe5325a324d..538d7aab8db5 100644 --- a/drivers/soc/aspeed/aspeed-lpc-snoop.c +++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c @@ -95,8 +95,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