From: Dan Carpenter <dan.carpenter@oracle.com> To: Jens Axboe <axboe@kernel.dk>, Will Drewry <wad@chromium.org> Cc: linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] block: fix an error code in add_partition() Date: Tue, 23 May 2017 17:28:36 +0300 [thread overview] Message-ID: <20170523142836.GB28346@elgon.mountain> (raw) We don't set an error code on this path. It means that we return NULL instead of an error pointer and the caller does a NULL dereference. Fixes: 6d1d8050b4bc ("block, partition: add partition_meta_info to hd_struct") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/block/partition-generic.c b/block/partition-generic.c index ff07b9143ca4..c5ec8246e25e 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -320,8 +320,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, if (info) { struct partition_meta_info *pinfo = alloc_part_info(disk); - if (!pinfo) + if (!pinfo) { + err = -ENOMEM; goto out_free_stats; + } memcpy(pinfo, info, sizeof(*info)); p->info = pinfo; }
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com> To: Jens Axboe <axboe@kernel.dk>, Will Drewry <wad@chromium.org> Cc: linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] block: fix an error code in add_partition() Date: Tue, 23 May 2017 14:28:36 +0000 [thread overview] Message-ID: <20170523142836.GB28346@elgon.mountain> (raw) We don't set an error code on this path. It means that we return NULL instead of an error pointer and the caller does a NULL dereference. Fixes: 6d1d8050b4bc ("block, partition: add partition_meta_info to hd_struct") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/block/partition-generic.c b/block/partition-generic.c index ff07b9143ca4..c5ec8246e25e 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -320,8 +320,10 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, if (info) { struct partition_meta_info *pinfo = alloc_part_info(disk); - if (!pinfo) + if (!pinfo) { + err = -ENOMEM; goto out_free_stats; + } memcpy(pinfo, info, sizeof(*info)); p->info = pinfo; }
next reply other threads:[~2017-05-23 14:28 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-05-23 14:28 Dan Carpenter [this message] 2017-05-23 14:28 ` [PATCH] block: fix an error code in add_partition() Dan Carpenter 2017-05-23 14:42 ` Jens Axboe 2017-05-23 14:42 ` Jens Axboe
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170523142836.GB28346@elgon.mountain \ --to=dan.carpenter@oracle.com \ --cc=axboe@kernel.dk \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=wad@chromium.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.