From patchwork Mon May 2 13:12:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 8992351 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 721FF9F39D for ; Mon, 2 May 2016 13:12:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A67EE201FE for ; Mon, 2 May 2016 13:12:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EE37201FA for ; Mon, 2 May 2016 13:12:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbcEBNMy (ORCPT ); Mon, 2 May 2016 09:12:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:39130 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753000AbcEBNMx (ORCPT ); Mon, 2 May 2016 09:12:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 795D5ABF6 for ; Mon, 2 May 2016 13:12:51 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 626B9DAB5D; Mon, 2 May 2016 15:12:36 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH] btrfs-progs: handle memory allocation error in cmd_device_stats Date: Mon, 2 May 2016 15:12:35 +0200 Message-Id: <1462194755-19618-1-git-send-email-dsterba@suse.com> X-Mailer: git-send-email 2.7.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Resolves-coverity-id: 1359012 Signed-off-by: David Sterba --- cmds-device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmds-device.c b/cmds-device.c index 5c0040c4f2ab..1c886ad58939 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -450,6 +450,10 @@ static int cmd_device_stats(int argc, char **argv) /* No path when device is missing. */ if (!canonical_path) { canonical_path = malloc(32); + if (!canonical_path) { + error("not enough memory for path buffer"); + goto out; + } snprintf(canonical_path, 32, "devid:%llu", args.devid); }