From patchwork Fri Aug 31 16:36:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10584185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4EA7139B for ; Fri, 31 Aug 2018 16:37:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9202E2C279 for ; Fri, 31 Aug 2018 16:37:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83BE82C2AC; Fri, 31 Aug 2018 16:37:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33A5E2C279 for ; Fri, 31 Aug 2018 16:37:01 +0000 (UTC) Received: from localhost ([::1]:54986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvmPr-00027U-Rh for patchwork-qemu-devel@patchwork.kernel.org; Fri, 31 Aug 2018 12:36:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvmOO-0000zb-Kk for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvmOI-00059n-H1 for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:55746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvmOG-000524-5k for qemu-devel@nongnu.org; Fri, 31 Aug 2018 12:35:21 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7VGYCqY185263 for ; Fri, 31 Aug 2018 16:35:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=p/3GpT6mCmpta1WDgi6uy9ouAWsAbVPq/7JoVAsXPOs=; b=AUz7k0qrjVPXLd5BWaySjb4cIFnxqvQ2RLz/wLliY3zceH0ZBrl2e0FC+iaxfKWYGlJF To5S8pSsWyBFZ21Ui0Q0BlT9c7kK6LP6iw0ISba7kkskqLLXVplRcqWmvybwOeqU0iIz Hd+RN8j2/o97X/zGCkmxECY7+CrVvJwxLo8ut4bolqFmXG/OiTGbNeuReu8Rg9X+Uo17 AAQEN/dAAfTI9N+AcOsLxhIjwnYwqc3NidC5LqhGTbG9sSqg/+N8zmbZTR8Q8cuo8Adx Qcp4PY8jMmZ4HsafOk1a70vRMh9P9Nk2v45mT1xlTm+UFE44eWnpddKL8tt/k+j0rUig jw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2m2y2q4ewk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 16:35:13 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7VGZCpL020268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 16:35:12 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7VGZCj1016221 for ; Fri, 31 Aug 2018 16:35:12 GMT Received: from ol7.nl.oracle.com (/10.175.61.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Aug 2018 09:35:11 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 31 Aug 2018 17:36:49 +0100 Message-Id: <1535733414-6812-4-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535733414-6812-1-git-send-email-Liam.Merwick@oracle.com> References: <1535733414-6812-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9001 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=930 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808310170 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH v2 3/8] block: Null pointer dereference in blk_root_get_parent_desc() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The dev_id returned by the call to blk_get_attached_dev_id() in blk_root_get_parent_desc() can be NULL (an internal call to object_get_canonical_path may have returned NULL) so it should be checked before dereferencing. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index fa120630be83..210eee75006a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -136,7 +136,7 @@ static char *blk_root_get_parent_desc(BdrvChild *child) } dev_id = blk_get_attached_dev_id(blk); - if (*dev_id) { + if (dev_id && *dev_id) { return dev_id; } else { /* TODO Callback into the BB owner for something more detailed */