From patchwork Thu Jul 9 10:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 11654131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9593F618 for ; Thu, 9 Jul 2020 10:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7CD7220708 for ; Thu, 9 Jul 2020 10:49:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DO08qp3L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726358AbgGIKtb (ORCPT ); Thu, 9 Jul 2020 06:49:31 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:52876 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726340AbgGIKtb (ORCPT ); Thu, 9 Jul 2020 06:49:31 -0400 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 069Afm4f001099; Thu, 9 Jul 2020 10:49:28 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=epbeuiFqfys3Wp6peU1GaxAQr03nxJTlGLw9bZw9BDs=; b=DO08qp3LtmItDMSnhvWnNkSSl5dPfEiPaIhzNcxqIdXY62sHuEv34gYJj4T2dQYbVagk zQqFjdjRToRJjOZsT28nNc4eFdigtl6++TnQJdivLKiLgVqH6dDzYHtkgucSl7FFkEAQ 1IsIXaQKghHpVmYwj0vj5CnUnFxBLOpYKwMkIW2nlESmz87HmWwcizr8LmXkix5rTDKD EgdU2OWNgkDrhv226yumWgMcsaj6zIsL6lAtxEQKDRxxbtx8vZInKAhVkMpp2Xkklau6 F8ftUy3j2yTHTrYBlachZboG/URY68+1mb41pTXNfCtxVu48pbrBv/KntSHOl9s/JuGz PQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 325y0agwy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 09 Jul 2020 10:49:28 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 069AnJpF074496; Thu, 9 Jul 2020 10:49:27 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 325k3h04s0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 09 Jul 2020 10:49:27 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 069AnQKK014612; Thu, 9 Jul 2020 10:49:27 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Jul 2020 03:49:26 -0700 Date: Thu, 9 Jul 2020 13:49:19 +0300 From: Dan Carpenter To: James Smart , Dick Kennedy Cc: "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] scsi: lpfc: Fix a condition in lpfc_dmp_dbg() Message-ID: <20200709104919.GD20875@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9676 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9676 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007090085 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org These variables are unsigned so the result of the subtraction is also unsigned and thus can't be negative. Change it to a comparison and remove the subtraction. Fixes: 372c187b8a70 ("scsi: lpfc: Add an internal trace log buffer") Signed-off-by: Dan Carpenter --- drivers/scsi/lpfc/lpfc_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7285b0114837..2bb2c96e7784 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -14152,7 +14152,7 @@ void lpfc_dmp_dbg(struct lpfc_hba *phba) if ((start_idx + dbg_cnt) > (DBG_LOG_SZ - 1)) { temp_idx = (start_idx + dbg_cnt) % DBG_LOG_SZ; } else { - if ((start_idx - dbg_cnt) < 0) { + if (start_idx > dbg_cnt) { start_idx = DBG_LOG_SZ - (dbg_cnt - start_idx); temp_idx = 0; } else {