From patchwork Tue Jan 9 09:37:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10151325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 84643603ED for ; Tue, 9 Jan 2018 09:37:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74C8328421 for ; Tue, 9 Jan 2018 09:37:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69ACC2885C; Tue, 9 Jan 2018 09:37:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A654128421 for ; Tue, 9 Jan 2018 09:37:27 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B50762675DF; Tue, 9 Jan 2018 10:37:25 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 878DB2675E1; Tue, 9 Jan 2018 10:37:23 +0100 (CET) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by alsa0.perex.cz (Postfix) with ESMTP id 1D30726717C for ; Tue, 9 Jan 2018 10:37:17 +0100 (CET) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w099bGHj149352; Tue, 9 Jan 2018 09:37:16 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-2017-10-26; bh=DYM2XIw1W2JAv8a4h8+TYm6u2BCM0b58wydQ/jj44qo=; b=C19mucdN882hx+jQ7g4t+PkyxlTEqv7716KoI+4/ob4TlVRVCC2oQzZ6oy1Wcx35JF0h YflT1uGDus1BKiohabpnLhADBa8+HD594GzUsp4S1k8VR5mzPwhNRwOLVjDskOA/4HSH L9d9++S4ilCuYqFU1IQ2PP48IC2jaHm3UDCBoRi8vV+l1OInw7TeKYcNt2IJTk76K+rn tEAQu7vwe+7YFHbxrscDcLjpL68BMB/jyxtir5JFPKs+TxCG1J1HV/GD5Xhk4F8pQI2G kxXqZigL5oLX9lh7QYYX5gbrt9Z98aiAlOjHJOfyWuINlnCYFOgpvWqfhyp8Dl/Jitp7 FQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2fcsmfgcnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 09 Jan 2018 09:37:16 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w099bBOc029596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Jan 2018 09:37:12 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w099bBYi019264; Tue, 9 Jan 2018 09:37:11 GMT Received: from mwanda (/197.157.34.162) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 09 Jan 2018 01:37:11 -0800 Date: Tue, 9 Jan 2018 12:37:00 +0300 From: Dan Carpenter To: Vinod Koul Message-ID: <20180109093700.7275ardpus7g6rkq@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8768 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=863 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801090135 Cc: Sanyog Kale , kernel-janitors@vger.kernel.org, alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH 1/2] soundwire: Fix a signedness bug X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP "ret" is an int and "buf" is a u8. sdw_read() returns negative error codes which are truncated to the u8, 0-255 range before being stored as an int. It means that "ret" can't be less than zero. Fixes: b0a9c37b0178 ("soundwire: Add slave status handling") Signed-off-by: Dan Carpenter diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 4c345197eb55..ac88031f7664 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -771,12 +771,13 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) sdw_modify_slave_status(slave, SDW_SLAVE_ALERT); /* Read Instat 1, Instat 2 and Instat 3 registers */ - ret = buf = sdw_read(slave, SDW_SCP_INT1); + ret = sdw_read(slave, SDW_SCP_INT1); if (ret < 0) { dev_err(slave->bus->dev, "SDW_SCP_INT1 read failed:%d", ret); return ret; } + buf = ret; ret = sdw_nread(slave, SDW_SCP_INTSTAT2, 2, buf2); if (ret < 0) { @@ -870,12 +871,13 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) * Read status again to ensure no new interrupts arrived * while servicing interrupts. */ - ret = _buf = sdw_read(slave, SDW_SCP_INT1); + ret = sdw_read(slave, SDW_SCP_INT1); if (ret < 0) { dev_err(slave->bus->dev, "SDW_SCP_INT1 read failed:%d", ret); return ret; } + _buf = ret; ret = sdw_nread(slave, SDW_SCP_INTSTAT2, 2, _buf2); if (ret < 0) {