Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1458788ybi; Thu, 30 May 2019 18:25:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVPeK5hYZRztqHyEDixhdyzakdEogc3K7hvUZ+2dC0jgpo/5eZYWHJsCv/k8Gw3Uc/c2d0 X-Received: by 2002:a63:1b65:: with SMTP id b37mr6333679pgm.408.1559265958893; Thu, 30 May 2019 18:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559265958; cv=none; d=google.com; s=arc-20160816; b=0Fo+tzv0XKiQyrgGXtqjR5/QxbjNJ2d+NOebNW5G8yreqzN4LOsAZM4PA07CHB9U7i MscDG8TDEhTvZns/ON9XX/AX29AI+UpT0rCYAJq3ejTa073ar/yuqMZV4cgnoKTZ0Yc3 Pj4wD5yz7tE4vVL4Cu6uzGw+qWn/XWUYNzoLMDL4ekTc4K5IFFS/+bn42WrU+niypdbX H8s55+jZ2Fgv6a5PJXXQoqwdMIcioNlUP1hWvmmJ7WXRxp6gUsaD7HtzaLtRMzGviJoj bv69JGNPDAQWU2DmJ0dbclPrC4ZGBx5PER4jvhCXPM4tJZCTfkocMp0FyDNINbRutJGf ELTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=PC1WfumcDjGU0yD+5JvFLw/e1vzZYICqxOgcNlrLZLs=; b=K6BxFmGXU3RkCCZwr9htnoyRt1nwVBJgU5WqyZDoWezTCWtyG/nz2ASMcOVYhP4Rjm zbfIXhB2FnZyfhH3+9VyC+zlHort1qLNuX+LS9In3PNyv/wK9jFDdEfeCByguJA7RVno f1kJYeoJHXbd9/7DKtZuSsPT/BXvnYavGNw1/N+0N2IjCcrxjh5aIonh4rINKp3EBUDo XzgyqwErq4DhRS9xs+v+KBrLX4kVdr1qB1RrDNQnEM7u/Gv1Wqu21UbDprZYnEfSnF/s QswIzghuhYVBjs69T6EwmAn+krl73D1x7k/5FHVWLARk8UMcO98CDs+l57Jr9iqxRDTF 6fHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aFgf8y4h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si4421581pgp.328.2019.05.30.18.25.42; Thu, 30 May 2019 18:25:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aFgf8y4h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbfEaBYg (ORCPT + 99 others); Thu, 30 May 2019 21:24:36 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:33913 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbfEaBYg (ORCPT ); Thu, 30 May 2019 21:24:36 -0400 Received: by mail-pf1-f195.google.com with SMTP id c14so2674785pfi.1; Thu, 30 May 2019 18:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=PC1WfumcDjGU0yD+5JvFLw/e1vzZYICqxOgcNlrLZLs=; b=aFgf8y4hxVqo2mpzXb79+1984QnsepjBu5R9D9FVKNJ4T0qgeM7XIkE0xS8vVVGXuu 5jWVOqNPrfqb3jvrGomCaykn13NSZ9TcFrq4JeopXIyYJQ4K5We4yEWTsAzIVZqmw2g/ /v6XEyGauJL1YvYGiqoMtBhehxgak2gT4SwYZvlKtCoNunBrs3NdoimWQ4y+Jq5VDRBJ H/BT+FcuLZYfoFG1ZhKJ5ho2A0UO79jsHX9c5FwZCmUZtRK4oypm2aBTZQqWqA9W0hAB aqPeSekT5N3TJBPh3Fcp0tlSZhIrqEB3TbF+t5Ye4BoTvTqavM331lDWFks76LhNi2WN tBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=PC1WfumcDjGU0yD+5JvFLw/e1vzZYICqxOgcNlrLZLs=; b=OuBN92KmeqUt7by4//5gGC1NzYl9dJzmpo4MF53JWrTfpzrUA+iGlD0toWT8S3lyuf HWga5dFf+WaiHw9NMc8ojaVGkc4T+9qjvnTj8GLzOrN63QVixam9Da2kDKuPTYVnkCGJ nRjUvpz+1wYMIheYk6eFw/Qw3z+JKy+5pUV+OpRLu5lGU4eUZrNTGAyi4TA8bKsz8noI Ze0WoRA/fRXfnEhPhXuyj/YN2YerjV4Dq/yK6cOzDXRs5/YU1vv0S3nlqVFST2dxP/lp a9PoMpNlfg5GzqQ8T9zxGSblMHsKFRiuzAsO5hRSskJm99/4V7skj3G3E+wziDU7n/2W IfyA== X-Gm-Message-State: APjAAAVkK4irLDhr5xw2iIFfpQ4OYnciBRcPnDHNFx3FqjZsXmjqkYLs IdPAD4y6HWlMHE8ibdW7VUIK2tMQ X-Received: by 2002:a62:4c5:: with SMTP id 188mr6714889pfe.19.1559265875653; Thu, 30 May 2019 18:24:35 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id a8sm4436752pfk.14.2019.05.30.18.24.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 18:24:35 -0700 (PDT) Date: Fri, 31 May 2019 09:24:18 +0800 From: Gen Zhang To: davem@davemloft.net, rppt@linux.vnet.ibm.com, mhocko@suse.com, akpm@linux-foundation.org, sfr@canb.auug.org.au Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mdesc: fix a missing-check bug in get_vdev_port_node_info() Message-ID: <20190531012418.GA4473@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In get_vdev_port_node_info(), 'node_info->vdev_port.name' is allcoated by kstrdup_const(), and it returns NULL when fails. So 'node_info->vdev_port.name' should be checked. Signed-off-by: Gen Zhang --- diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c index 9a26b44..8e645dd 100644 --- a/arch/sparc/kernel/mdesc.c +++ b/arch/sparc/kernel/mdesc.c @@ -356,6 +356,8 @@ static int get_vdev_port_node_info(struct mdesc_handle *md, u64 node, node_info->vdev_port.id = *idp; node_info->vdev_port.name = kstrdup_const(name, GFP_KERNEL); + if (!node_info->vdev_port.name) + return -1; node_info->vdev_port.parent_cfg_hdl = *parent_cfg_hdlp; return 0; ---