From patchwork Thu Aug 28 13:14:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 36197 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A71620551 for ; Thu, 28 Aug 2014 13:14:39 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf18348115pad.6 for ; Thu, 28 Aug 2014 06:14:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=zJ17gjxShg3WWb4OTe6QecsUTwIj31Lg1l55C2HOmOU=; b=Hscxj4dXEcexc4w8fj87XugsHXC/XbEdMY0kLePWx8OglCvAVyE5N6gIySriwnPucK Y/q6BKcKHRLgSHHO0wbAF0zhzhrlC3wE9L57ECxS1T3evfa8cR5phbnyetsV64A0OMKS X5ENZaYwOtoi4/NcK08AVPkE2E3GlCzLDxv1oX2xD1Rl9y8ik8ST4pk05XzzYb5thZFb IcDKIrjC1htgo6UcxMQasuQGsogAQP/S2uwakhMZ2/gHDXJVO1F9OcONlIFEacMkyGCn /UNqCn9sxJu4f616MpLucx/0Kkyx6FLjYUfux+KgaGITNSqXpy9u6U0jMf0SVwMpcFZ5 dSgA== X-Gm-Message-State: ALoCoQnXtPMw4KXXAGntMIEsWLojHRQOhE8Y0bGva45BGGPqIS7honaIo6edlGY20pJsHGwmzGC0 X-Received: by 10.66.245.197 with SMTP id xq5mr2076317pac.42.1409231674413; Thu, 28 Aug 2014 06:14:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.21 with SMTP id h21ls614244qge.52.gmail; Thu, 28 Aug 2014 06:14:34 -0700 (PDT) X-Received: by 10.52.36.176 with SMTP id r16mr424522vdj.70.1409231674260; Thu, 28 Aug 2014 06:14:34 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id dd1si3364335vdc.26.2014.08.28.06.14.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 06:14:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so769104vcb.11 for ; Thu, 28 Aug 2014 06:14:34 -0700 (PDT) X-Received: by 10.52.94.108 with SMTP id db12mr2547860vdb.8.1409231674181; Thu, 28 Aug 2014 06:14:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp234626vcb; Thu, 28 Aug 2014 06:14:33 -0700 (PDT) X-Received: by 10.50.79.201 with SMTP id l9mr37342387igx.17.1409231673636; Thu, 28 Aug 2014 06:14:33 -0700 (PDT) Received: from mail-ie0-f170.google.com (mail-ie0-f170.google.com [209.85.223.170]) by mx.google.com with ESMTPS id wy7si4048942icb.49.2014.08.28.06.14.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 06:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of lee.jones@linaro.org designates 209.85.223.170 as permitted sender) client-ip=209.85.223.170; Received: by mail-ie0-f170.google.com with SMTP id rl12so924955iec.1 for ; Thu, 28 Aug 2014 06:14:33 -0700 (PDT) X-Received: by 10.50.28.75 with SMTP id z11mr37897398igg.11.1409231673391; Thu, 28 Aug 2014 06:14:33 -0700 (PDT) Received: from localhost.localdomain (host86-152-0-170.range86-152.btcentralplus.com. [86.152.0.170]) by mx.google.com with ESMTPSA id w8sm16633672igl.13.2014.08.28.06.14.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Aug 2014 06:14:33 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Lee Jones , gregkh@linuxfoundation.org Subject: [PATCH 02/11] misc: st_core: Protect unsigned value against becoming negative Date: Thu, 28 Aug 2014 14:14:08 +0100 Message-Id: <1409231657-18294-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409231657-18294-1-git-send-email-lee.jones@linaro.org> References: <1409231657-18294-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Coverity reported: This less-than-zero comparison of an unsigned value is never true. In answer to that, we only ever decrement if protos_registered is positive. We can subsequently remove the paranoid checking during unregister. Cc: gregkh@linuxfoundation.org Signed-off-by: Lee Jones --- drivers/misc/ti-st/st_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 1972d57a..54be83d 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c @@ -153,8 +153,9 @@ static void st_reg_complete(struct st_data_s *st_gdata, char err) (st_gdata->list[i]->priv_data, err); pr_info("protocol %d's cb sent %d\n", i, err); if (err) { /* cleanup registered protocol */ - st_gdata->protos_registered--; st_gdata->is_registered[i] = false; + if (st_gdata->protos_registered) + st_gdata->protos_registered--; } } } @@ -639,14 +640,12 @@ long st_unregister(struct st_proto_s *proto) return -EPROTONOSUPPORT; } - st_gdata->protos_registered--; + if (st_gdata->protos_registered) + st_gdata->protos_registered--; + remove_channel_from_table(st_gdata, proto); spin_unlock_irqrestore(&st_gdata->lock, flags); - /* paranoid check */ - if (st_gdata->protos_registered < ST_EMPTY) - st_gdata->protos_registered = ST_EMPTY; - if ((st_gdata->protos_registered == ST_EMPTY) && (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { pr_info(" all chnl_ids unregistered ");