From patchwork Sun Jan 16 20:50:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 482701 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0GKjBPW028150 for ; Sun, 16 Jan 2011 20:50:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753875Ab1APUuL (ORCPT ); Sun, 16 Jan 2011 15:50:11 -0500 Received: from swampdragon.chaosbits.net ([90.184.90.115]:16667 "EHLO swampdragon.chaosbits.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753666Ab1APUuK (ORCPT ); Sun, 16 Jan 2011 15:50:10 -0500 Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 456E29403F; Sun, 16 Jan 2011 21:50:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 3E1429403B; Sun, 16 Jan 2011 21:50:09 +0100 (CET) Date: Sun, 16 Jan 2011 21:50:09 +0100 (CET) From: Jesper Juhl To: linux-nfs@vger.kernel.org cc: Trond Myklebust , linux-kernel@vger.kernel.org Subject: [PATCH] NFS4: Avoid potential NULL pointer dereference in decode_and_add_ds(). Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 16 Jan 2011 20:50:13 +0000 (UTC) diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index 51fe64a..5a85b8f 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c @@ -214,7 +214,7 @@ decode_and_add_ds(__be32 **pp, struct inode *inode) /* ipv6 length plus port is legal */ if (rlen > INET6_ADDRSTRLEN + 8) { - dprintk("%s Invalid address, length %d\n", __func__, + dprintk("%s: Invalid address, length %d\n", __func__, rlen); goto out_err; } @@ -225,6 +225,11 @@ decode_and_add_ds(__be32 **pp, struct inode *inode) /* replace the port dots with dashes for the in4_pton() delimiter*/ for (i = 0; i < 2; i++) { char *res = strrchr(buf, '.'); + if (!res) { + dprintk("%s: Failed finding expected dots in port\n", + __func__); + goto out_free; + } *res = '-'; }