Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965868AbcKAErz convert rfc822-to-8bit (ORCPT ); Tue, 1 Nov 2016 00:47:55 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:48287 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965810AbcKAErV (ORCPT ); Tue, 1 Nov 2016 00:47:21 -0400 MIME-Version: 1.0 Message-ID: <8eb8496b-16d7-4be7-bc43-6ff3f2b8708e@default> Date: Mon, 31 Oct 2016 21:46:09 -0700 (PDT) From: Dongli Zhang To: , JBeulich Cc: , , , , , Subject: Re: [PATCH 1/1] xen-netfront: do not cast grant table reference to signed short X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-Disposition: inline X-Source-IP: aserv0022.oracle.com [141.146.126.234] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1703 Lines: 49 Hi David and Jan, I did more testing on the code. Casting to either (long) or (unsigned long) would be fine. However, there is still an issue that ref is of type uint32_t and IS_ERR_VALUE((unsigned long)ref) would not return true when ref=-ENOSPC (or other error code). IS_ERR_VALUE((long)ref) would return false as well. The solution is to cast ref to (int) first as follows: - BUG_ON((signed short)ref < 0); + WARN_ON_ONCE(IS_ERR_VALUE((unsigned long)(int)ref)); David, I am very sorry for this error and I will be careful the next time. Would you please let me know if I should resend a new patch or an incremental based on previous one at https://git.kernel.org/cgit/linux/kernel/git/davem/net.git? Thank you very much! Dongli Zhang ----- Original Message ----- From: davem@davemloft.net To: dongli.zhang@oracle.com Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org, boris.ostrovsky@oracle.com, david.vrabel@citrix.com, jgross@suse.com Sent: Tuesday, November 1, 2016 4:06:27 AM GMT +08:00 Beijing / Chongqing / Hong Kong / Urumqi Subject: Re: [PATCH 1/1] xen-netfront: do not cast grant table reference to signed short From: Dongli Zhang Date: Mon, 31 Oct 2016 13:38:29 +0800 > While grant reference is of type uint32_t, xen-netfront erroneously casts > it to signed short in BUG_ON(). > > This would lead to the xen domU panic during boot-up or migration when it > is attached with lots of paravirtual devices. > > Signed-off-by: Dongli Zhang Since this is consistent with how the macros in linux/err.h handle "is this an error" checks, this change looks good to me. Applied, thanks.