All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: manivannan.sadhasivam@linaro.org
Cc: linux-mtd@lists.infradead.org
Subject: [bug report] mtd: parsers: Add Qcom SMEM parser
Date: Fri, 8 Jan 2021 15:52:41 +0300	[thread overview]
Message-ID: <X/hVmWrQqLd09/KJ@mwanda> (raw)

Hello Manivannan Sadhasivam,

The patch 803eb124e1a6: "mtd: parsers: Add Qcom SMEM parser" from Jan
4, 2021, leads to the following static checker warning:

	drivers/mtd/parsers/qcomsmempart.c:109 parse_qcomsmem_part()
	warn: passing zero to 'PTR_ERR'

drivers/mtd/parsers/qcomsmempart.c
    68          pr_debug("Parsing partition table info from SMEM\n");
    69          ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, &len);
    70          if (IS_ERR(ptable)) {

Can "ptable" be NULL here?

    71                  pr_err("Error reading partition table header\n");
    72                  return PTR_ERR(ptable);
    73          }
    74  
    75          /* Verify ptable magic */
    76          if (le32_to_cpu(ptable->magic1) != SMEM_FLASH_PART_MAGIC1 ||
    77              le32_to_cpu(ptable->magic2) != SMEM_FLASH_PART_MAGIC2) {
    78                  pr_err("Partition table magic verification failed\n");
    79                  return -EINVAL;
    80          }
    81  
    82          /* Ensure that # of partitions is less than the max we have allocated */
    83          numparts = le32_to_cpu(ptable->numparts);
    84          if (numparts > SMEM_FLASH_PTABLE_MAX_PARTS_V4) {
    85                  pr_err("Partition numbers exceed the max limit\n");
    86                  return -EINVAL;
    87          }
    88  
    89          /* Find out length of partition data based on table version */
    90          if (le32_to_cpu(ptable->version) <= SMEM_FLASH_PTABLE_V3) {
    91                  len = SMEM_FLASH_PTABLE_HDR_LEN + SMEM_FLASH_PTABLE_MAX_PARTS_V3 *
    92                          sizeof(struct smem_flash_pentry);
    93          } else if (le32_to_cpu(ptable->version) == SMEM_FLASH_PTABLE_V4) {
    94                  len = SMEM_FLASH_PTABLE_HDR_LEN + SMEM_FLASH_PTABLE_MAX_PARTS_V4 *
    95                          sizeof(struct smem_flash_pentry);
    96          } else {
    97                  pr_err("Unknown ptable version (%d)", le32_to_cpu(ptable->version));
    98                  return -EINVAL;
    99          }
   100  
   101          /*
   102           * Now that the partition table header has been parsed, verified
   103           * and the length of the partition table calculated, read the
   104           * complete partition table
   105           */
   106          ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, &len);
   107          if (IS_ERR_OR_NULL(ptable)) {
   108                  pr_err("Error reading partition table\n");
   109                  return PTR_ERR(ptable);

If "ptable" is NULL then this code returns success.  It's not clear if
that's intentional.  If it is then just ignore this email.  Thanks!

   110          }
   111  
   112          parts = kcalloc(numparts, sizeof(*parts), GFP_KERNEL);

regards,
dan carpenter

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

             reply	other threads:[~2021-01-08 12:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 12:52 Dan Carpenter [this message]
2021-01-08 13:28 ` [bug report] mtd: parsers: Add Qcom SMEM parser Manivannan Sadhasivam
2021-01-08 14:57   ` Dan Carpenter

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=X/hVmWrQqLd09/KJ@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=manivannan.sadhasivam@linaro.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: link
Be 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.