From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753999AbcKLVh3 (ORCPT ); Sat, 12 Nov 2016 16:37:29 -0500 Received: from s3.sipsolutions.net ([5.9.151.49]:42830 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751427AbcKLVh0 (ORCPT ); Sat, 12 Nov 2016 16:37:26 -0500 Message-ID: <1478986636.4226.4.camel@sipsolutions.net> Subject: Re: [PATCH] genetlink: fix unsigned int comparison with less than zero From: Johannes Berg To: Cong Wang , Colin King Cc: "David S . Miller" , pravin shelar , Wei Yongjun , Florian Westphal , Tycho Andersen , Tom Herbert , Linux Kernel Network Developers , LKML Date: Sat, 12 Nov 2016 22:37:16 +0100 In-Reply-To: (sfid-20161110_181214_593279_4F3243C4) References: <20161110155758.26996-1-colin.king@canonical.com> (sfid-20161110_181214_593279_4F3243C4) Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5-1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2016-11-10 at 09:11 -0800, Cong Wang wrote: > On Thu, Nov 10, 2016 at 7:57 AM, Colin King > wrote: > > > > From: Colin Ian King > > > > family->id is unsigned, so the less than zero check for > > failure return from idr_alloc is never true and so the error exit > > is never handled.  Instead, assign err and check if this is less > > than zero since this is a signed integer. > > Why family->id can't be just signed int? For me it should be. I suppose it could be, since family IDs are allocated in a 16-bit range anyway. But family IDs can also never actually be negative, so having an unsigned int in the struct makes sense too. I tend to think this patch is fine. johannes