Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp341426pxj; Thu, 20 May 2021 10:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeo05++6BllJx4xRlYMO2L6terYqq1Z2oKUZ0b2/hxc5rMABzshEJqXVBS03Cd13HKqMns X-Received: by 2002:aa7:cb84:: with SMTP id r4mr6186278edt.187.1621531906760; Thu, 20 May 2021 10:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531906; cv=none; d=google.com; s=arc-20160816; b=RTuFshQOCTf1i5vJAEnLudILHnZ0T2z5KZbWAraS5En9dEZMhMHn+cY0Krj42Emar0 0bu6xUz72pu3pbohyvxs+TYMaVxkE9bVhQJP/vN4VBjln8veKj/OZwpj8SyphhK//wHZ /CzflZVPmXVJabj4UwgUjUqJArBDDQ4I1BKVJGG6Rp7BPBmAstmIL+lsf412rWtjFzJx 0neOy7AlabvCfGEjZ2cKsvg7lUvvOGoKajxi58lHcOWFeg7ZqAxWChRm8InU7GFIVafg OIEoU6G63wPtIDJJMIHZYI9qYxFGyUnxEXxopo0BVo2l01wAhDF8QXej9quPRdgtk6rV KWcQ== 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=bcXo9YZomM+Ty/dGLsWK3Nwp0+f4SOhN2YAQoyz+Cww=; b=cJ+ih0FNY68HbarUAGZL+HUAxQfrWfOQ3HOGCLpFPayemOUqZdBF34qCKIzQQXjlgS 7L52k64iAWHmtaGk429iE2WH32H5Lp7LZLpLj48fwuds+kZiHubMq4y2SbJxz6AJGKZm LwTKnVNVHywRe92FpLTJzIEhyzkoNJjCQfgC/APrzXkN4kJxapbKzCvrjuHNfwwXbEAv o7ZGe47176m8P0RxhUGR9JzUsOCFOgtryjSmlv6dIK7eNf40yjoobY2810rfO0mBS0ru i0i745FMM223OMpzfRt6av+P8ewav5IdkxrpgWBZyL51+Brfd+czbaLM0zSFaaf/wvhn E0zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gjOhUmJg; 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 w13si3374116ede.340.2021.05.20.10.31.23; Thu, 20 May 2021 10:31:46 -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=gjOhUmJg; 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 S234072AbhETKA0 (ORCPT + 99 others); Thu, 20 May 2021 06:00:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235123AbhETJzv (ORCPT ); Thu, 20 May 2021 05:55:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85C22613B4; Thu, 20 May 2021 09:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503445; bh=bBkE66/Q8JF/rMUl905Rn1myBRKl5hrHfu1zTOb7ggc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjOhUmJgRMK2OUO96RakXHoyRu767XRNbL6W9b9hrDX1EgjkpGkYKhMHzeH09pMyM ZSiseSaTjNi4gBxBAVGd9hCsz0Tx/ys+VIhYcHxIOwwVmebiqlYU4sJNKnMI2UTwnF S0ugqCraEervNAhyAMJUGzKNQ+ZATKLPGd10n6o0= 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 4.19 225/425] soc: aspeed: fix a ternary sign expansion bug Date: Thu, 20 May 2021 11:19:54 +0200 Message-Id: <20210520092138.815562664@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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/misc/aspeed-lpc-snoop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/misc/aspeed-lpc-snoop.c b/drivers/misc/aspeed-lpc-snoop.c index b4a776bf44bc..e2cb0b9607d1 100644 --- a/drivers/misc/aspeed-lpc-snoop.c +++ b/drivers/misc/aspeed-lpc-snoop.c @@ -99,8 +99,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